Add audio mixer mute enable

This commit is contained in:
twinaphex 2017-06-08 23:53:24 +02:00
parent cdd7fbeb52
commit cdf7a403ea
12 changed files with 60 additions and 6 deletions

View File

@ -148,6 +148,7 @@ static size_t audio_driver_buffer_size = 0;
static size_t audio_driver_data_ptr = 0;
static bool audio_driver_control = false;
static bool audio_driver_mixer_mute_enable = false;
static bool audio_driver_mute_enable = false;
static bool audio_driver_use_float = false;
static bool audio_driver_active = false;
@ -534,6 +535,8 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
bool is_slowmotion = false;
const void *output_data = NULL;
unsigned output_frames = 0;
float audio_volume_gain = !audio_driver_mute_enable ?
audio_driver_volume_gain : 0.0f;
src_data.data_in = NULL;
src_data.data_out = NULL;
@ -553,7 +556,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
return false;
convert_s16_to_float(audio_driver_input_data, data, samples,
audio_driver_mute_enable ? 0.0f : audio_driver_volume_gain);
audio_volume_gain);
src_data.data_in = audio_driver_input_data;
src_data.input_frames = samples >> 1;
@ -622,8 +625,14 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
audio_driver_resampler->process(audio_driver_resampler_data, &src_data);
if (audio_mixer_active)
audio_mixer_mix(audio_driver_output_samples_buf, src_data.output_frames,
audio_driver_mixer_volume_gain);
{
bool override = audio_driver_mixer_mute_enable ? true :
(audio_driver_mixer_volume_gain != 0.0f) ? true : false;
float mixer_gain = !audio_driver_mixer_mute_enable ?
audio_driver_mixer_volume_gain : 0.0f;
audio_mixer_mix(audio_driver_output_samples_buf,
src_data.output_frames, mixer_gain, override);
}
output_data = audio_driver_output_samples_buf;
output_frames = (unsigned)src_data.output_frames;
@ -1141,6 +1150,12 @@ bool audio_driver_toggle_mute(void)
return true;
}
bool audio_driver_mixer_toggle_mute(void)
{
audio_driver_mixer_mute_enable = !audio_driver_mixer_mute_enable;
return true;
}
static INLINE bool audio_driver_alive(void)
{
if ( current_audio
@ -1274,6 +1289,8 @@ bool *audio_get_bool_ptr(enum audio_action action)
{
switch (action)
{
case AUDIO_ACTION_MIXER_MUTE_ENABLE:
return &audio_driver_mixer_mute_enable;
case AUDIO_ACTION_MUTE_ENABLE:
return &audio_driver_mute_enable;
case AUDIO_ACTION_NONE:

View File

@ -38,6 +38,7 @@ enum audio_action
{
AUDIO_ACTION_NONE = 0,
AUDIO_ACTION_RATE_CONTROL_DELTA,
AUDIO_ACTION_MIXER_MUTE_ENABLE,
AUDIO_ACTION_MUTE_ENABLE,
AUDIO_ACTION_VOLUME_GAIN,
AUDIO_ACTION_MIXER_VOLUME_GAIN,

View File

@ -1153,6 +1153,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("core_set_supports_no_game_enable", &settings->bools.set_supports_no_game_enable, true, true, false);
SETTING_BOOL("audio_enable", &settings->bools.audio_enable, true, audio_enable, false);
SETTING_BOOL("audio_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE), true, false, false);
SETTING_BOOL("audio_mixer_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MIXER_MUTE_ENABLE), true, false, false);
SETTING_BOOL("location_allow", &settings->bools.location_allow, true, false, false);
SETTING_BOOL("video_font_enable", &settings->bools.video_font_enable, true, font_enable, false);
SETTING_BOOL("core_updater_auto_extract_archive", &settings->bools.network_buildbot_auto_extract_archive, true, true, false);

View File

@ -1235,3 +1235,5 @@ MSG_HASH(MENU_ENUM_LABEL_FILTER_BY_CURRENT_CORE,
"filter_by_current_Core")
MSG_HASH(MENU_ENUM_LABEL_AUDIO_MIXER_VOLUME,
"audio_mixer_volume")
MSG_HASH(MENU_ENUM_LABEL_AUDIO_MIXER_MUTE,
"audio_mixer_mute_enable")

View File

@ -3029,3 +3029,9 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_VOLUME,
"Audio Mixer Volume Level (dB)"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_MUTE,
"Audio Mixer Mute"
)
MSG_HASH(MENU_ENUM_SUBLABEL_AUDIO_MIXER_MUTE,
"Mute/unmute mixer audio.")

View File

@ -608,7 +608,7 @@ again:
}
#endif
void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override)
void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bool override)
{
unsigned i;
size_t j = 0;
@ -621,7 +621,7 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override)
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++)
{
float volume = (volume_override == 0.0f) ? voice->volume : volume_override;
float volume = (override) ? volume_override : voice->volume;
switch (voice->type)
{

View File

@ -67,7 +67,7 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound,
void audio_mixer_stop(audio_mixer_voice_t* voice);
void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override);
void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bool override);
RETRO_END_DECLS

View File

@ -98,6 +98,7 @@ default_sublabel_macro(action_bind_sublabel_video_shared_context, MENU_
default_sublabel_macro(action_bind_sublabel_audio_latency, MENU_ENUM_SUBLABEL_AUDIO_LATENCY)
default_sublabel_macro(action_bind_sublabel_audio_rate_control_delta, MENU_ENUM_SUBLABEL_AUDIO_RATE_CONTROL_DELTA)
default_sublabel_macro(action_bind_sublabel_audio_mute, MENU_ENUM_SUBLABEL_AUDIO_MUTE)
default_sublabel_macro(action_bind_sublabel_audio_mixer_mute, MENU_ENUM_SUBLABEL_AUDIO_MIXER_MUTE)
default_sublabel_macro(action_bind_sublabel_camera_allow, MENU_ENUM_SUBLABEL_CAMERA_ALLOW)
default_sublabel_macro(action_bind_sublabel_location_allow, MENU_ENUM_SUBLABEL_LOCATION_ALLOW)
default_sublabel_macro(action_bind_sublabel_input_max_users, MENU_ENUM_SUBLABEL_INPUT_MAX_USERS)
@ -1062,6 +1063,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_AUDIO_MUTE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_mute);
break;
case MENU_ENUM_LABEL_AUDIO_MIXER_MUTE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_mixer_mute);
break;
case MENU_ENUM_LABEL_AUDIO_LATENCY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_latency);
break;

View File

@ -5644,6 +5644,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_AUDIO_MUTE,
PARSE_ONLY_BOOL, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_AUDIO_MIXER_MUTE,
PARSE_ONLY_BOOL, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_AUDIO_VOLUME,
PARSE_ONLY_FLOAT, false);

View File

@ -3805,6 +3805,22 @@ static bool setting_append_list(
SD_FLAG_NONE
);
CONFIG_BOOL(
list, list_info,
audio_get_bool_ptr(AUDIO_ACTION_MIXER_MUTE_ENABLE),
MENU_ENUM_LABEL_AUDIO_MIXER_MUTE,
MENU_ENUM_LABEL_VALUE_AUDIO_MIXER_MUTE,
false,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);
CONFIG_FLOAT(
list, list_info,
&settings->floats.audio_volume,

View File

@ -973,6 +973,7 @@ enum msg_hash_enums
MENU_LABEL(AUDIO_BLOCK_FRAMES),
MENU_LABEL(AUDIO_DSP_PLUGIN),
MENU_LABEL(AUDIO_MUTE),
MENU_LABEL(AUDIO_MIXER_MUTE),
MENU_LABEL(AUDIO_SYNC),
MENU_LABEL(AUDIO_VOLUME),
MENU_LABEL(AUDIO_MIXER_VOLUME),

View File

@ -284,6 +284,9 @@
# Mutes audio.
# audio_mute_enable = false
# Mutes audio mixer volume globally.
# audio_mixer_mute_enable = false
# Audio output samplerate.
# audio_out_rate = 48000