Skip to content

Commit

Permalink
Separate ffmpeg and audiomixer conditionals (#15872)
Browse files Browse the repository at this point in the history
There are cases when mixer exists without ffmpeg. In such cases,
some music content can still be added to the mixer for playback.
Logic added to separate the two cases.
  • Loading branch information
zoltanvb authored Nov 5, 2023
1 parent c9de6e5 commit e35afdb
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 31 deletions.
2 changes: 1 addition & 1 deletion intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -12737,7 +12737,7 @@ MSG_HASH(
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_RUN_MUSIC,
"Run"
"Play in Media Player"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_SECONDS,
Expand Down
20 changes: 18 additions & 2 deletions menu/cbs/menu_cbs_deferred_push.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ static int general_push(menu_displaylist_info_t *info,
char newstring2[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_state_get_ptr()->driver_data;
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) || defined (HAVE_AUDIOMIXER)
bool
multimedia_builtin_mediaplayer_enable = settings->bools.multimedia_builtin_mediaplayer_enable;
#endif
Expand Down Expand Up @@ -559,13 +559,29 @@ static int general_push(menu_displaylist_info_t *info,
string_list_initialize(&str_list3);
string_split_noalloc(&str_list3, newstring, "|");

#ifdef HAVE_IBXM
#if defined(HAVE_AUDIOMIXER)
if (multimedia_builtin_mediaplayer_enable)
{
union string_list_elem_attr attr;
attr.i = 0;
#if defined(HAVE_DR_MP3)
string_list_append(&str_list3, "mp3", attr);
#endif
#if defined(HAVE_STB_VORBIS)
string_list_append(&str_list3, "ogg", attr);
#endif
#if defined(HAVE_DR_FLAC)
string_list_append(&str_list3, "flac", attr);
#endif
#if defined(HAVE_RWAV)
string_list_append(&str_list3, "wav", attr);
#endif
#ifdef HAVE_IBXM

string_list_append(&str_list3, "s3m", attr);
string_list_append(&str_list3, "mod", attr);
string_list_append(&str_list3, "xm", attr);
#endif
}
#endif
string_list_join_concat(newstring2, sizeof(newstring2),
Expand Down
32 changes: 21 additions & 11 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
#if defined(HAVE_MATERIALUI) || defined(HAVE_XMB) || defined(HAVE_OZONE)
#include "menu_screensaver.h"
#endif
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
#include "../../cores/internal_cores.h"
#endif

#include "../configuration.h"
#include "../file_path_special.h"
Expand Down Expand Up @@ -406,7 +409,7 @@ static int filebrowser_parse(
switch (path_type)
{
case RARCH_CONTENT_MUSIC:
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) || defined(HAVE_AUDIOMIXER)
if (builtin_mediaplayer_enable)
file_type = FILE_TYPE_MUSIC;
#endif
Expand Down Expand Up @@ -12167,17 +12170,18 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
#endif /* HAVE_LIBNX */
case DISPLAYLIST_MUSIC_LIST:
{
bool multimedia_builtin_mediaplayer_enable = settings->bools.multimedia_builtin_mediaplayer_enable;
char combined_path[PATH_MAX_LENGTH];
const char *ext = NULL;

fill_pathname_join_special(combined_path, menu->scratch2_buf,
menu->scratch_buf, sizeof(combined_path));
ext = path_get_extension(combined_path);
menu_entries_clear(info->list);

#ifdef HAVE_AUDIOMIXER
if (multimedia_builtin_mediaplayer_enable)
{
char combined_path[PATH_MAX_LENGTH];
const char *ext = NULL;

fill_pathname_join_special(combined_path, menu->scratch2_buf,
menu->scratch_buf, sizeof(combined_path));

ext = path_get_extension(combined_path);

if (audio_driver_mixer_extension_supported(ext))
{
if (menu_entries_append(info->list,
Expand All @@ -12198,9 +12202,15 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
#endif

#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
if (multimedia_builtin_mediaplayer_enable)
{
bool multimedia_builtin_mediaplayer_enable = settings->bools.multimedia_builtin_mediaplayer_enable;
if (multimedia_builtin_mediaplayer_enable)
struct retro_system_info sysinfo = {0};
#if defined(HAVE_FFMPEG)
libretro_ffmpeg_retro_get_system_info(&sysinfo);
#elif defined(HAVE_MPV)
libretro_mpv_retro_get_system_info(&sysinfo);
#endif
if (strstr(sysinfo.valid_extensions,ext))
{
if (menu_entries_append(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RUN_MUSIC),
Expand Down
28 changes: 19 additions & 9 deletions msg_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,16 +800,8 @@ enum msg_file_type msg_hash_to_file_type(uint32_t hash)
return FILE_TYPE_MOV;
case MENU_VALUE_FILE_WMV:
return FILE_TYPE_WMV;
case MENU_VALUE_FILE_MP3:
return FILE_TYPE_MP3;
case MENU_VALUE_FILE_M4A:
return FILE_TYPE_M4A;
case MENU_VALUE_FILE_OGG:
return FILE_TYPE_OGG;
case MENU_VALUE_FILE_FLAC:
return FILE_TYPE_FLAC;
case MENU_VALUE_FILE_WAV:
return FILE_TYPE_WAV;
case MENU_VALUE_FILE_3G2:
return FILE_TYPE_3G2;
case MENU_VALUE_FILE_MPG:
Expand All @@ -835,14 +827,32 @@ enum msg_file_type msg_hash_to_file_type(uint32_t hash)
case MENU_VALUE_FILE_WMA:
return FILE_TYPE_WMA;
#endif
#ifdef HAVE_IBXM
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) || defined(HAVE_AUDIOMIXER)
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_DR_MP3)
case MENU_VALUE_FILE_MP3:
return FILE_TYPE_MP3;
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_STB_VORBIS)
case MENU_VALUE_FILE_OGG:
return FILE_TYPE_OGG;
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_DR_FLAC)
case MENU_VALUE_FILE_FLAC:
return FILE_TYPE_FLAC;
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_RWAV)
case MENU_VALUE_FILE_WAV:
return FILE_TYPE_WAV;
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_IBXM)
case MENU_VALUE_FILE_MOD:
return FILE_TYPE_MOD;
case MENU_VALUE_FILE_S3M:
return FILE_TYPE_S3M;
case MENU_VALUE_FILE_XM:
return FILE_TYPE_XM;
#endif
#endif
#ifdef HAVE_IMAGEVIEWER
case MENU_VALUE_FILE_JPG:
case MENU_VALUE_FILE_JPG_CAPS:
Expand Down
24 changes: 16 additions & 8 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2036,11 +2036,26 @@ enum rarch_content_type path_is_media_type(const char *path)
case FILE_TYPE_MXF:
return RARCH_CONTENT_MOVIE;
case FILE_TYPE_WMA:
case FILE_TYPE_M4A:
#endif
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV) || defined(HAVE_AUDIOMIXER)
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_STB_VORBIS)
case FILE_TYPE_OGG:
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_DR_MP3)
case FILE_TYPE_MP3:
case FILE_TYPE_M4A:
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_DR_FLAC)
case FILE_TYPE_FLAC:
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_RWAV)
case FILE_TYPE_WAV:
#endif
#if !defined(HAVE_AUDIOMIXER) || defined(HAVE_IBXM)
case FILE_TYPE_MOD:
case FILE_TYPE_S3M:
case FILE_TYPE_XM:
#endif
return RARCH_CONTENT_MUSIC;
#endif
#ifdef HAVE_IMAGEVIEWER
Expand All @@ -2050,13 +2065,6 @@ enum rarch_content_type path_is_media_type(const char *path)
case FILE_TYPE_BMP:
return RARCH_CONTENT_IMAGE;
#endif
#ifdef HAVE_IBXM
case FILE_TYPE_MOD:
case FILE_TYPE_S3M:
case FILE_TYPE_XM:
return RARCH_CONTENT_MUSIC;
#endif

case FILE_TYPE_NONE:
default:
break;
Expand Down

0 comments on commit e35afdb

Please sign in to comment.