Start adding mixer controls - ability to stop and remove loaded tracks

This commit is contained in:
twinaphex 2018-04-30 14:34:25 +02:00
parent 05ea2cff96
commit 965859ddcb
31 changed files with 429 additions and 62 deletions

View File

@ -45,8 +45,6 @@
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
#define AUDIO_MIXER_MAX_STREAMS 8
static const audio_driver_t *audio_drivers[] = {
#ifdef HAVE_ALSA
&audio_alsa,
@ -122,18 +120,6 @@ static const audio_driver_t *audio_drivers[] = {
NULL,
};
struct audio_mixer_stream
{
audio_mixer_sound_t *handle;
audio_mixer_voice_t *voice;
audio_mixer_stop_cb_t stop_cb;
enum audio_mixer_state state;
float volume;
void *buf;
size_t bufsize;
};
static unsigned audio_mixer_current_max_idx = 0;
static struct audio_mixer_stream audio_mixer_streams[AUDIO_MIXER_MAX_STREAMS] = {{0}};
static size_t audio_driver_chunk_size = 0;
@ -193,6 +179,13 @@ enum resampler_quality audio_driver_get_resampler_quality(void)
return (enum resampler_quality)settings->uints.audio_resampler_quality;
}
audio_mixer_stream_t *audio_driver_mixer_get_stream(unsigned i)
{
if (i > (AUDIO_MIXER_MAX_STREAMS-1))
return NULL;
return &audio_mixer_streams[i];
}
/**
* compute_audio_buffer_statistics:
*
@ -1035,18 +1028,12 @@ static void audio_mixer_play_stop_cb(
{
unsigned i = (unsigned)idx;
#if 0
if (audio_mixer_streams[i].buf != NULL)
free(audio_mixer_streams[i].buf);
#endif
audio_mixer_streams[i].state = AUDIO_STREAM_STATE_NONE;
audio_mixer_streams[i].volume = 0.0f;
audio_mixer_streams[i].buf = NULL;
audio_mixer_streams[i].stop_cb = NULL;
audio_mixer_streams[i].handle = NULL;
audio_mixer_streams[i].voice = NULL;
audio_mixer_current_max_idx--;
}
break;
case AUDIO_MIXER_SOUND_STOPPED:
@ -1056,15 +1043,31 @@ static void audio_mixer_play_stop_cb(
}
}
bool audio_driver_mixer_get_free_stream_slot(unsigned *id)
{
unsigned i;
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
{
if (audio_mixer_streams[i].state == AUDIO_STREAM_STATE_NONE)
{
*id = i;
return true;
}
}
return false;
}
bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
{
unsigned free_slot = 0;
audio_mixer_voice_t *voice = NULL;
audio_mixer_sound_t *handle = NULL;
audio_mixer_stop_cb_t stop_cb = audio_mixer_play_stop_cb;
bool looped = false;
void *buf = NULL;
if (audio_mixer_current_max_idx >= AUDIO_MIXER_MAX_STREAMS)
if (!audio_driver_mixer_get_free_stream_slot(&free_slot))
return false;
if (params->state == AUDIO_STREAM_STATE_NONE)
@ -1121,50 +1124,84 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
audio_mixer_active = true;
}
audio_mixer_streams[audio_mixer_current_max_idx].buf = buf;
audio_mixer_streams[audio_mixer_current_max_idx].handle = handle;
audio_mixer_streams[audio_mixer_current_max_idx].voice = voice;
audio_mixer_streams[audio_mixer_current_max_idx].state = params->state;
audio_mixer_streams[audio_mixer_current_max_idx].volume = params->volume;
audio_mixer_streams[audio_mixer_current_max_idx].stop_cb = stop_cb;
audio_mixer_current_max_idx++;
audio_mixer_streams[free_slot].buf = buf;
audio_mixer_streams[free_slot].handle = handle;
audio_mixer_streams[free_slot].voice = voice;
audio_mixer_streams[free_slot].state = params->state;
audio_mixer_streams[free_slot].volume = params->volume;
audio_mixer_streams[free_slot].stop_cb = stop_cb;
return true;
}
static void audio_driver_mixer_remove_stream(unsigned i)
enum audio_mixer_state audio_driver_mixer_get_stream_state(unsigned i)
{
audio_mixer_sound_t *handle = audio_mixer_streams[i].handle;
audio_mixer_voice_t *voice = audio_mixer_streams[i].voice;
if (i >= AUDIO_MIXER_MAX_STREAMS)
return AUDIO_STREAM_STATE_NONE;
return audio_mixer_streams[i].state;
}
void audio_driver_mixer_stop_stream(unsigned i)
{
bool set_state = false;
if (i >= AUDIO_MIXER_MAX_STREAMS)
return;
switch (audio_mixer_streams[i].state)
{
case AUDIO_STREAM_STATE_PLAYING:
if (voice)
audio_mixer_stop(voice);
if (handle)
audio_mixer_destroy(handle);
break;
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
if (voice)
audio_mixer_stop(voice);
if (handle)
audio_mixer_destroy(handle);
set_state = true;
break;
case AUDIO_STREAM_STATE_STOPPED:
if (handle)
audio_mixer_destroy(handle);
case AUDIO_STREAM_STATE_NONE:
break;
}
if (set_state)
{
audio_mixer_voice_t *voice = audio_mixer_streams[i].voice;
if (voice)
audio_mixer_stop(voice);
audio_mixer_streams[i].state = AUDIO_STREAM_STATE_STOPPED;
}
}
void audio_driver_mixer_remove_stream(unsigned i)
{
bool destroy = false;
if (i >= AUDIO_MIXER_MAX_STREAMS)
return;
switch (audio_mixer_streams[i].state)
{
case AUDIO_STREAM_STATE_PLAYING:
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
audio_driver_mixer_stop_stream(i);
destroy = true;
break;
case AUDIO_STREAM_STATE_STOPPED:
destroy = true;
break;
case AUDIO_STREAM_STATE_NONE:
break;
}
audio_mixer_streams[i].state = AUDIO_STREAM_STATE_NONE;
audio_mixer_streams[i].volume = 0.0f;
audio_mixer_streams[i].stop_cb = NULL;
audio_mixer_streams[i].handle = NULL;
audio_mixer_streams[i].voice = NULL;
if (destroy)
{
audio_mixer_sound_t *handle = audio_mixer_streams[i].handle;
if (handle)
audio_mixer_destroy(handle);
audio_mixer_streams[i].state = AUDIO_STREAM_STATE_NONE;
audio_mixer_streams[i].volume = 0.0f;
audio_mixer_streams[i].stop_cb = NULL;
audio_mixer_streams[i].handle = NULL;
audio_mixer_streams[i].voice = NULL;
}
}
static void audio_driver_mixer_deinit(void)
@ -1174,9 +1211,11 @@ static void audio_driver_mixer_deinit(void)
audio_mixer_active = false;
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
{
audio_driver_mixer_stop_stream(i);
audio_driver_mixer_remove_stream(i);
}
audio_mixer_current_max_idx = 0;
audio_mixer_done();
}

View File

@ -35,6 +35,8 @@ RETRO_BEGIN_DECLS
#define AUDIO_MAX_RATIO 16
#define AUDIO_MIXER_MAX_STREAMS 8
enum audio_action
{
AUDIO_ACTION_NONE = 0,
@ -46,6 +48,25 @@ enum audio_action
AUDIO_ACTION_MIXER
};
enum audio_mixer_state
{
AUDIO_STREAM_STATE_NONE = 0,
AUDIO_STREAM_STATE_STOPPED,
AUDIO_STREAM_STATE_PLAYING,
AUDIO_STREAM_STATE_PLAYING_LOOPED
};
typedef struct audio_mixer_stream
{
audio_mixer_sound_t *handle;
audio_mixer_voice_t *voice;
audio_mixer_stop_cb_t stop_cb;
enum audio_mixer_state state;
float volume;
void *buf;
size_t bufsize;
} audio_mixer_stream_t;
typedef struct audio_statistics
{
float average_buffer_saturation;
@ -137,14 +158,6 @@ typedef struct audio_driver
size_t (*buffer_size)(void *data);
} audio_driver_t;
enum audio_mixer_state
{
AUDIO_STREAM_STATE_NONE = 0,
AUDIO_STREAM_STATE_STOPPED,
AUDIO_STREAM_STATE_PLAYING,
AUDIO_STREAM_STATE_PLAYING_LOOPED
};
typedef struct audio_mixer_stream_params
{
float volume;
@ -273,10 +286,18 @@ bool audio_driver_init(void);
void audio_driver_menu_sample(void);
audio_mixer_stream_t *audio_driver_mixer_get_stream(unsigned i);
bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params);
void audio_driver_mixer_stop_stream(unsigned i);
void audio_driver_mixer_remove_stream(unsigned i);
enum resampler_quality audio_driver_get_resampler_quality(void);
enum audio_mixer_state audio_driver_mixer_get_stream_state(unsigned i);
bool compute_audio_buffer_statistics(audio_statistics_t *stats);
extern audio_driver_t audio_rsound;

View File

@ -3461,3 +3461,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3247,3 +3247,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3239,3 +3239,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3353,3 +3353,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3112,3 +3112,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -5843,3 +5843,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3277,3 +3277,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3335,3 +3335,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Abilita l'audio del menu")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Abilita o disabilita il suono del menu.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3351,3 +3351,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3238,3 +3238,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -271,6 +271,8 @@ MSG_HASH(MENU_ENUM_LABEL_DEFERRED_ARCHIVE_OPEN_DETECT_CORE,
"deferred_archive_open_detect_core")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST,
"deferred_audio_settings_list")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_AUDIO_MIXER_SETTINGS_LIST,
"deferred_audio_mixer_settings_list")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST,
"deferred_configuration_settings_list")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_LIST,
@ -1487,3 +1489,7 @@ MSG_HASH(MENU_ENUM_LABEL_CONTENT_SHOW_OVERLAYS,
"menu_show_overlay_settings")
MSG_HASH(MENU_ENUM_LABEL_AUDIO_ENABLE_MENU,
"audio_enable_menu")
MSG_HASH(MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS,
"audio_mixer_settings")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST,
"deferred_mixer_stream_settings_list")

View File

@ -3114,3 +3114,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3473,3 +3473,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -4342,3 +4342,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3212,3 +3212,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3296,3 +3296,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3510,3 +3510,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -3269,3 +3269,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE_MENU,
"Enable menu audio")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_ENABLE_MENU,
"Enable or disable menu sound.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
"Mixer Settings")
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_SETTINGS,
"View and/or modify audio mixer settings.")

View File

@ -134,6 +134,7 @@ generic_deferred_push(deferred_push_core_settings_list, DISPLAYLIST_
generic_deferred_push(deferred_push_video_settings_list, DISPLAYLIST_VIDEO_SETTINGS_LIST)
generic_deferred_push(deferred_push_configuration_settings_list, DISPLAYLIST_CONFIGURATION_SETTINGS_LIST)
generic_deferred_push(deferred_push_saving_settings_list, DISPLAYLIST_SAVING_SETTINGS_LIST)
generic_deferred_push(deferred_push_mixer_stream_settings_list, DISPLAYLIST_MIXER_STREAM_SETTINGS_LIST)
generic_deferred_push(deferred_push_logging_settings_list, DISPLAYLIST_LOGGING_SETTINGS_LIST)
generic_deferred_push(deferred_push_frame_throttle_settings_list, DISPLAYLIST_FRAME_THROTTLE_SETTINGS_LIST)
generic_deferred_push(deferred_push_rewind_settings_list, DISPLAYLIST_REWIND_SETTINGS_LIST)
@ -154,6 +155,7 @@ generic_deferred_push(deferred_push_user_settings_list, DISPLAYLIST_
generic_deferred_push(deferred_push_directory_settings_list, DISPLAYLIST_DIRECTORY_SETTINGS_LIST)
generic_deferred_push(deferred_push_privacy_settings_list, DISPLAYLIST_PRIVACY_SETTINGS_LIST)
generic_deferred_push(deferred_push_audio_settings_list, DISPLAYLIST_AUDIO_SETTINGS_LIST)
generic_deferred_push(deferred_push_audio_mixer_settings_list, DISPLAYLIST_AUDIO_MIXER_SETTINGS_LIST)
generic_deferred_push(deferred_push_input_settings_list, DISPLAYLIST_INPUT_SETTINGS_LIST)
generic_deferred_push(deferred_push_latency_settings_list, DISPLAYLIST_LATENCY_SETTINGS_LIST)
generic_deferred_push(deferred_push_recording_settings_list, DISPLAYLIST_RECORDING_SETTINGS_LIST)
@ -624,6 +626,11 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_saving_settings_list);
return 0;
}
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST)))
{
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_mixer_stream_settings_list);
return 0;
}
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST)))
{
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_logging_settings_list);
@ -809,6 +816,11 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
{
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_settings_list);
}
else if (strstr(label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_AUDIO_MIXER_SETTINGS_LIST)))
{
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_audio_mixer_settings_list);
}
else if (strstr(label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LATENCY_SETTINGS_LIST)))
{

View File

@ -45,6 +45,7 @@
#include "../menu_content.h"
#include "../menu_shader.h"
#include "../../audio/audio_driver.h"
#include "../../core.h"
#include "../../configuration.h"
#include "../../core_info.h"
@ -247,6 +248,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
{
switch (lbl)
{
case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST;
case ACTION_OK_DL_ACCOUNTS_LIST:
return MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST;
case ACTION_OK_DL_INPUT_SETTINGS_LIST:
@ -307,6 +310,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
return MENU_ENUM_LABEL_DEFERRED_PRIVACY_SETTINGS_LIST;
case ACTION_OK_DL_AUDIO_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST;
case ACTION_OK_DL_AUDIO_MIXER_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_AUDIO_MIXER_SETTINGS_LIST;
case ACTION_OK_DL_INPUT_HOTKEY_BINDS_LIST:
return MENU_ENUM_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST;
case ACTION_OK_DL_RECORDING_SETTINGS_LIST:
@ -798,6 +803,7 @@ int generic_action_ok_displaylist_push(const char *path,
MENU_ENUM_LABEL_DEFERRED_CORE_LIST_SET;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST:
case ACTION_OK_DL_ACCOUNTS_LIST:
case ACTION_OK_DL_INPUT_SETTINGS_LIST:
case ACTION_OK_DL_LATENCY_SETTINGS_LIST:
@ -828,6 +834,7 @@ int generic_action_ok_displaylist_push(const char *path,
case ACTION_OK_DL_DIRECTORY_SETTINGS_LIST:
case ACTION_OK_DL_PRIVACY_SETTINGS_LIST:
case ACTION_OK_DL_AUDIO_SETTINGS_LIST:
case ACTION_OK_DL_AUDIO_MIXER_SETTINGS_LIST:
case ACTION_OK_DL_INPUT_HOTKEY_BINDS_LIST:
case ACTION_OK_DL_RECORDING_SETTINGS_LIST:
case ACTION_OK_DL_PLAYLIST_SETTINGS_LIST:
@ -851,6 +858,20 @@ int generic_action_ok_displaylist_push(const char *path,
break;
}
/* second pass */
switch (action_type)
{
case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST:
{
unsigned player_no = type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN;
info.type = MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN + player_no;
}
break;
default:
break;
}
if (info_label)
info.label = strdup(info_label);
if (info_path)
@ -1746,6 +1767,44 @@ error:
return menu_cbs_exit();
}
static int action_ok_mixer_stream_action_remove(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
unsigned stream_id = type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_BEGIN;
enum audio_mixer_state state = audio_driver_mixer_get_stream_state(stream_id);
switch (state)
{
case AUDIO_STREAM_STATE_PLAYING:
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
case AUDIO_STREAM_STATE_STOPPED:
audio_driver_mixer_remove_stream(stream_id);
break;
case AUDIO_STREAM_STATE_NONE:
break;
}
return 0;
}
static int action_ok_mixer_stream_action_stop(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
unsigned stream_id = type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_BEGIN;
enum audio_mixer_state state = audio_driver_mixer_get_stream_state(stream_id);
switch (state)
{
case AUDIO_STREAM_STATE_PLAYING:
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
audio_driver_mixer_stop_stream(stream_id);
break;
case AUDIO_STREAM_STATE_STOPPED:
case AUDIO_STREAM_STATE_NONE:
break;
}
return 0;
}
static int action_ok_lookup_setting(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -3200,6 +3259,7 @@ default_action_ok_func(action_ok_netplay_sublist, ACTION_OK_DL_NETPLAY)
default_action_ok_func(action_ok_directory_list, ACTION_OK_DL_DIRECTORY_SETTINGS_LIST)
default_action_ok_func(action_ok_privacy_list, ACTION_OK_DL_PRIVACY_SETTINGS_LIST)
default_action_ok_func(action_ok_rdb_entry, ACTION_OK_DL_RDB_ENTRY)
default_action_ok_func(action_ok_mixer_stream_actions, ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST)
default_action_ok_func(action_ok_browse_url_list, ACTION_OK_DL_BROWSE_URL_LIST)
default_action_ok_func(action_ok_core_list, ACTION_OK_DL_CORE_LIST)
default_action_ok_func(action_ok_cheat_file, ACTION_OK_DL_CHEAT_FILE)
@ -3221,6 +3281,7 @@ default_action_ok_func(action_ok_push_video_settings_list, ACTION_OK_DL_VIDEO_SE
default_action_ok_func(action_ok_push_configuration_settings_list, ACTION_OK_DL_CONFIGURATION_SETTINGS_LIST)
default_action_ok_func(action_ok_push_core_settings_list, ACTION_OK_DL_CORE_SETTINGS_LIST)
default_action_ok_func(action_ok_push_audio_settings_list, ACTION_OK_DL_AUDIO_SETTINGS_LIST)
default_action_ok_func(action_ok_push_audio_mixer_settings_list, ACTION_OK_DL_AUDIO_MIXER_SETTINGS_LIST)
default_action_ok_func(action_ok_push_input_settings_list, ACTION_OK_DL_INPUT_SETTINGS_LIST)
default_action_ok_func(action_ok_push_latency_settings_list, ACTION_OK_DL_LATENCY_SETTINGS_LIST)
default_action_ok_func(action_ok_push_recording_settings_list, ACTION_OK_DL_RECORDING_SETTINGS_LIST)
@ -4222,6 +4283,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_AUDIO_SETTINGS:
BIND_ACTION_OK(cbs, action_ok_push_audio_settings_list);
break;
case MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS:
BIND_ACTION_OK(cbs, action_ok_push_audio_mixer_settings_list);
break;
case MENU_ENUM_LABEL_LATENCY_SETTINGS:
BIND_ACTION_OK(cbs, action_ok_push_latency_settings_list);
break;
@ -4568,6 +4632,21 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
{
BIND_ACTION_OK(cbs, action_ok_lookup_setting);
}
else if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_BEGIN
&& type <= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_END)
{
BIND_ACTION_OK(cbs, action_ok_mixer_stream_action_remove);
}
else if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_BEGIN
&& type <= MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_END)
{
BIND_ACTION_OK(cbs, action_ok_mixer_stream_action_stop);
}
else if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN
&& type <= MENU_SETTINGS_AUDIO_MIXER_STREAM_END)
{
BIND_ACTION_OK(cbs, action_ok_mixer_stream_actions);
}
else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PARAMETER_LAST)
{

View File

@ -15,6 +15,7 @@
#include <compat/strl.h>
#include "../../audio/audio_driver.h"
#include "../menu_driver.h"
#include "../menu_cbs.h"
@ -460,6 +461,40 @@ static int action_bind_sublabel_remap_kbd_sublabel(
return 0;
}
static int action_bind_sublabel_audio_mixer_stream(
file_list_t *list,
unsigned type, unsigned i,
const char *label, const char *path,
char *s, size_t len)
{
char msg[64];
unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN);
settings_t *settings = config_get_ptr();
audio_mixer_stream_t *stream = audio_driver_mixer_get_stream(offset);
if (!stream)
return 0;
switch (stream->state)
{
case AUDIO_STREAM_STATE_NONE:
strlcpy(msg, "N/A", sizeof(msg));
break;
case AUDIO_STREAM_STATE_STOPPED:
strlcpy(msg, "Stopped", sizeof(msg));
break;
case AUDIO_STREAM_STATE_PLAYING:
strlcpy(msg, "Playing", sizeof(msg));
break;
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
strlcpy(msg, "Playing (Looped)", sizeof(msg));
break;
}
snprintf(s, len, "State : %s | Volume: %.2f dB", msg,
stream->volume);
return 0;
}
static int action_bind_sublabel_remap_sublabel(
file_list_t *list,
@ -553,6 +588,13 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_remap_sublabel);
}
if (type >= MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN
&& type <= MENU_SETTINGS_AUDIO_MIXER_STREAM_END)
{
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_mixer_stream);
return 0;
}
if (cbs->enum_idx != MSG_UNKNOWN)
{
switch (cbs->enum_idx)

View File

@ -124,6 +124,7 @@ default_title_macro(action_get_directory_settings_list, MENU_ENUM_LABEL_
default_title_macro(action_get_privacy_settings_list, MENU_ENUM_LABEL_VALUE_PRIVACY_SETTINGS)
default_title_macro(action_get_updater_settings_list, MENU_ENUM_LABEL_VALUE_UPDATER_SETTINGS)
default_title_macro(action_get_audio_settings_list, MENU_ENUM_LABEL_VALUE_AUDIO_SETTINGS)
default_title_macro(action_get_audio_mixer_settings_list, MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS)
default_title_macro(action_get_input_settings_list, MENU_ENUM_LABEL_VALUE_INPUT_SETTINGS)
default_title_macro(action_get_latency_settings_list, MENU_ENUM_LABEL_VALUE_LATENCY_SETTINGS)
default_title_macro(action_get_core_cheat_options_list, MENU_ENUM_LABEL_VALUE_CORE_CHEAT_OPTIONS)
@ -476,6 +477,11 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
BIND_ACTION_GET_TITLE(cbs, action_get_audio_settings_list);
return 0;
}
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_AUDIO_MIXER_SETTINGS_LIST)))
{
BIND_ACTION_GET_TITLE(cbs, action_get_audio_mixer_settings_list);
return 0;
}
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LATENCY_SETTINGS_LIST)))
{
BIND_ACTION_GET_TITLE(cbs, action_get_latency_settings_list);

View File

@ -68,6 +68,7 @@ enum
ACTION_OK_DL_DRIVER_SETTINGS_LIST,
ACTION_OK_DL_VIDEO_SETTINGS_LIST,
ACTION_OK_DL_AUDIO_SETTINGS_LIST,
ACTION_OK_DL_AUDIO_MIXER_SETTINGS_LIST,
ACTION_OK_DL_LATENCY_SETTINGS_LIST,
ACTION_OK_DL_CONFIGURATION_SETTINGS_LIST,
ACTION_OK_DL_SAVING_SETTINGS_LIST,
@ -107,6 +108,7 @@ enum
ACTION_OK_DL_CORE_CONTENT_DIRS_SUBDIR_LIST,
ACTION_OK_DL_DEFERRED_CORE_LIST,
ACTION_OK_DL_DEFERRED_CORE_LIST_SET,
ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST,
ACTION_OK_DL_ONSCREEN_DISPLAY_SETTINGS_LIST,
ACTION_OK_DL_ONSCREEN_OVERLAY_SETTINGS_LIST,
ACTION_OK_DL_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST,

View File

@ -4252,6 +4252,45 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
FILE_TYPE_PLAYLIST_ENTRY, 0, 0);
#endif
}
info->need_push = true;
info->need_refresh = true;
info->need_clear = true;
break;
case DISPLAYLIST_MIXER_STREAM_SETTINGS_LIST:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
{
char lbl_remove[PATH_MAX_LENGTH];
char lbl_stop[PATH_MAX_LENGTH];
unsigned id = info->type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN;
lbl_remove[0] = lbl_stop[0] = '\0';
snprintf(lbl_stop, sizeof(lbl_stop), "mixer_stream_%d_action_stop", id);
snprintf(lbl_remove, sizeof(lbl_remove), "mixer_stream_%d_action_remove", id);
menu_entries_append_enum(info->list,
"Stop",
lbl_stop,
MSG_UNKNOWN,
(MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_BEGIN + id),
0, 0);
menu_entries_append_enum(info->list,
"Remove",
lbl_remove,
MSG_UNKNOWN,
(MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_BEGIN + id),
0, 0);
count++;
if (count == 0)
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
FILE_TYPE_NONE, 0, 0);
}
info->need_push = true;
info->need_refresh = true;
info->need_clear = true;
@ -6054,6 +6093,35 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
info->need_refresh = true;
info->need_push = true;
break;
case DISPLAYLIST_AUDIO_MIXER_SETTINGS_LIST:
{
unsigned i;
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
for (i = 0; i < AUDIO_MIXER_MAX_STREAMS; i++)
{
char msg[128];
char msg_lbl[128];
snprintf(msg, sizeof(msg), "Mixer Stream #%d :\n", i+1);
snprintf(msg_lbl, sizeof(msg_lbl), "audio_mixer_stream_%d\n", i);
menu_entries_append_enum(info->list, msg, msg_lbl,
MSG_UNKNOWN,
(MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN + i),
0, 0);
count++;
}
if (count == 0)
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND),
msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND),
MENU_ENUM_LABEL_NO_SETTINGS_FOUND,
0, 0, 0);
info->need_refresh = true;
info->need_push = true;
}
break;
case DISPLAYLIST_AUDIO_SETTINGS_LIST:
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
menu_displaylist_parse_settings_enum(menu, info,
@ -6244,6 +6312,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
MENU_ENUM_LABEL_VIDEO_SETTINGS, PARSE_ACTION, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_AUDIO_SETTINGS, PARSE_ACTION, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS, PARSE_ACTION, false);
ret = menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_SETTINGS, PARSE_ACTION, false);
ret = menu_displaylist_parse_settings_enum(menu, info,

View File

@ -110,6 +110,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_ACHIEVEMENT_LIST,
DISPLAYLIST_USER_BINDS_LIST,
DISPLAYLIST_ACCOUNTS_LIST,
DISPLAYLIST_MIXER_STREAM_SETTINGS_LIST,
DISPLAYLIST_DRIVER_SETTINGS_LIST,
DISPLAYLIST_VIDEO_SETTINGS_LIST,
DISPLAYLIST_CONFIGURATION_SETTINGS_LIST,
@ -118,6 +119,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_FRAME_THROTTLE_SETTINGS_LIST,
DISPLAYLIST_REWIND_SETTINGS_LIST,
DISPLAYLIST_AUDIO_SETTINGS_LIST,
DISPLAYLIST_AUDIO_MIXER_SETTINGS_LIST,
DISPLAYLIST_CORE_SETTINGS_LIST,
DISPLAYLIST_INPUT_SETTINGS_LIST,
DISPLAYLIST_LATENCY_SETTINGS_LIST,

View File

@ -188,6 +188,15 @@ enum menu_settings_type
MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_IMAGE_APPEND,
MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_CYCLE_TRAY_STATUS,
MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN,
MENU_SETTINGS_AUDIO_MIXER_STREAM_END = MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN + 7,
MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN,
MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_END = MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN + 7,
MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_BEGIN,
MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_END = MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_STOP_BEGIN + 7,
MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_BEGIN,
MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_END = MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_REMOVE_BEGIN + 7,
MENU_SETTINGS_BIND_BEGIN,
MENU_SETTINGS_BIND_LAST = MENU_SETTINGS_BIND_BEGIN + RARCH_ANALOG_RIGHT_Y_MINUS,
MENU_SETTINGS_BIND_ALL_LAST = MENU_SETTINGS_BIND_BEGIN + RARCH_MENU_TOGGLE,

View File

@ -2243,6 +2243,14 @@ static bool setting_append_list(
&subgroup_info,
parent_group);
CONFIG_ACTION(
list, list_info,
MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS,
MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_SETTINGS,
&group_info,
&subgroup_info,
parent_group);
CONFIG_ACTION(
list, list_info,
MENU_ENUM_LABEL_INPUT_SETTINGS,

View File

@ -938,6 +938,7 @@ enum msg_hash_enums
MENU_LABEL(BROWSE_URL),
MENU_LABEL(BROWSE_START),
/* Deferred */
MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST,
MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST,
MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST,
@ -1011,6 +1012,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_DEFERRED_PRIVACY_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_AUDIO_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_AUDIO_MIXER_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_USER_BINDS_LIST,
MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST,
@ -1488,6 +1490,7 @@ enum msg_hash_enums
MENU_LABEL(DRIVER_SETTINGS),
MENU_LABEL(VIDEO_SETTINGS),
MENU_LABEL(AUDIO_SETTINGS),
MENU_LABEL(AUDIO_MIXER_SETTINGS),
MENU_LABEL(LATENCY_SETTINGS),
MENU_LABEL(CORE_SETTINGS),
MENU_LABEL(CONFIGURATION_SETTINGS),

View File

@ -89,7 +89,7 @@ static void task_audio_mixer_handle_upload_ogg(void *task_data,
if (!img)
return;
params.volume = 1.0f;
params.volume = 0.0f;
params.type = AUDIO_MIXER_TYPE_OGG;
params.state = AUDIO_STREAM_STATE_PLAYING;
params.buf = img->buf;
@ -111,7 +111,7 @@ static void task_audio_mixer_handle_upload_flac(void *task_data,
if (!img)
return;
params.volume = 1.0f;
params.volume = 0.0f;
params.type = AUDIO_MIXER_TYPE_FLAC;
params.state = AUDIO_STREAM_STATE_PLAYING;
params.buf = img->buf;
@ -133,7 +133,7 @@ static void task_audio_mixer_handle_upload_mp3(void *task_data,
if (!img)
return;
params.volume = 1.0f;
params.volume = 0.0f;
params.type = AUDIO_MIXER_TYPE_MP3;
params.state = AUDIO_STREAM_STATE_PLAYING;
params.buf = img->buf;
@ -155,7 +155,7 @@ static void task_audio_mixer_handle_upload_mod(void *task_data,
if (!img)
return;
params.volume = 1.0f;
params.volume = 0.0f;
params.type = AUDIO_MIXER_TYPE_MOD;
params.state = AUDIO_STREAM_STATE_PLAYING;
params.buf = img->buf;
@ -177,7 +177,7 @@ static void task_audio_mixer_handle_upload_wav(void *task_data,
if (!img)
return;
params.volume = 1.0f;
params.volume = 0.0f;
params.type = AUDIO_MIXER_TYPE_WAV;
params.state = AUDIO_STREAM_STATE_PLAYING;
params.buf = img->buf;