mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Add 'Add to Mixer' option for Ogg/WAV files inside the music tab
This commit is contained in:
parent
0b3ef16982
commit
5851d103d0
@ -25,6 +25,7 @@
|
||||
#include <audio/dsp_filter.h>
|
||||
#include <file/file_path.h>
|
||||
#include <lists/dir_list.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
@ -893,6 +894,33 @@ bool audio_driver_get_devices_list(void **data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio_driver_mixer_extension_supported(const char *ext)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
unsigned i;
|
||||
bool ret = false;
|
||||
struct string_list *str_list = string_list_new();
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
string_list_append(str_list, "ogg", attr);
|
||||
string_list_append(str_list, "wav", attr);
|
||||
|
||||
for (i = 0; i < str_list->size; i++)
|
||||
{
|
||||
const char *str_ext = str_list->elems[i].data;
|
||||
if (string_is_equal(str_ext, ext))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string_list_free(str_list);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
|
||||
{
|
||||
audio_mixer_voice_t *voice = NULL;
|
||||
|
@ -199,6 +199,8 @@ void audio_driver_sample_rewind(int16_t left, int16_t right);
|
||||
|
||||
size_t audio_driver_sample_batch_rewind(const int16_t *data, size_t frames);
|
||||
|
||||
bool audio_driver_mixer_extension_supported(const char *ext);
|
||||
|
||||
void audio_driver_set_volume_gain(float gain);
|
||||
|
||||
void audio_driver_dsp_filter_free(void);
|
||||
|
@ -1221,3 +1221,5 @@ MSG_HASH(MENU_ENUM_LABEL_SHADER_PIPELINE_BOKEH,
|
||||
"shader_pipeline_bokeh")
|
||||
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER,
|
||||
"netplay_use_mitm_server")
|
||||
MSG_HASH(MENU_ENUM_LABEL_ADD_TO_MIXER,
|
||||
"audio_add_to_mixer")
|
||||
|
@ -3009,3 +3009,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_USE_MITM_SERVER,
|
||||
"Use MITM Server")
|
||||
MSG_HASH(MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER,
|
||||
"Forward netplay connections through a man-in-the-middle server. Useful if the host is behind a firewall or has NAT/UPnP problems.")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER,
|
||||
"Add to mixer")
|
||||
|
@ -1696,6 +1696,26 @@ static int action_ok_lookup_setting(const char *path,
|
||||
return menu_setting_set(type, label, MENU_ACTION_OK, false);
|
||||
}
|
||||
|
||||
static int action_ok_audio_add_to_mixer(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
const char *entry_path = NULL;
|
||||
playlist_t *tmp_playlist = NULL;
|
||||
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
|
||||
|
||||
if (!tmp_playlist)
|
||||
return -1;
|
||||
|
||||
playlist_get_index(tmp_playlist, entry_idx,
|
||||
&entry_path, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if(path_file_exists(entry_path))
|
||||
task_push_audio_mixer_load(entry_path,
|
||||
NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_ok_menu_wallpaper(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
@ -4319,6 +4339,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
|
||||
{
|
||||
switch (cbs->enum_idx)
|
||||
{
|
||||
case MENU_ENUM_LABEL_ADD_TO_MIXER:
|
||||
BIND_ACTION_OK(cbs, action_ok_audio_add_to_mixer);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_WALLPAPER:
|
||||
BIND_ACTION_OK(cbs, action_ok_menu_wallpaper);
|
||||
break;
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "widgets/menu_filebrowser.h"
|
||||
#include "menu_cbs.h"
|
||||
|
||||
#include "../audio/audio_driver.h"
|
||||
#include "../configuration.h"
|
||||
#include "../file_path_special.h"
|
||||
#include "../defaults.h"
|
||||
@ -2936,6 +2937,17 @@ static int menu_displaylist_parse_horizontal_content_actions(
|
||||
menu_displaylist_parse_load_content_settings(info);
|
||||
else
|
||||
{
|
||||
const char *ext = path_get_extension(entry_path);
|
||||
|
||||
if (audio_driver_mixer_extension_supported(ext))
|
||||
{
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ADD_TO_MIXER),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_ADD_TO_MIXER),
|
||||
MENU_ENUM_LABEL_ADD_TO_MIXER,
|
||||
FILE_TYPE_PLAYLIST_ENTRY, 0, idx);
|
||||
}
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RUN),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_RUN),
|
||||
|
@ -376,6 +376,7 @@ enum msg_hash_enums
|
||||
MSG_EXTRACTING_FILE,
|
||||
MSG_NO_CONTENT_STARTING_DUMMY_CORE,
|
||||
|
||||
MENU_LABEL(ADD_TO_MIXER),
|
||||
MENU_ENUM_LABEL_MENU_TOGGLE,
|
||||
|
||||
MENU_LABEL(NO_HISTORY_AVAILABLE),
|
||||
|
Loading…
Reference in New Issue
Block a user