Skip to content

Commit

Permalink
Fix segfault when accessing 'Audio' menu on platforms without mixer s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
jdgleaver committed Aug 23, 2021
1 parent 1ad0251 commit f505d62
Showing 1 changed file with 55 additions and 51 deletions.
106 changes: 55 additions & 51 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -5987,58 +5987,62 @@ unsigned menu_displaylist_build_list(
count++;
break;
case DISPLAYLIST_AUDIO_SETTINGS_LIST:
{
bool audio_mute_enable = *audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE);
bool audio_mixer_mute_enable= *audio_get_bool_ptr(AUDIO_ACTION_MIXER_MUTE_ENABLE);
menu_displaylist_build_info_selective_t build_list[] = {
{MENU_ENUM_LABEL_AUDIO_OUTPUT_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_RESAMPLER_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_SYNCHRONIZATION_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_MIDI_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS, PARSE_ACTION, false },
{MENU_ENUM_LABEL_MENU_SOUNDS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_MIXER_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_FASTFORWARD_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_VOLUME, PARSE_ONLY_FLOAT, false },
{MENU_ENUM_LABEL_AUDIO_MIXER_VOLUME, PARSE_ONLY_FLOAT, false },
{MENU_ENUM_LABEL_SYSTEM_BGM_ENABLE, PARSE_ONLY_BOOL, true },
#ifdef HAVE_DSP_FILTER
{MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, PARSE_ONLY_PATH, true },
#endif
};

for (i = 0; i < ARRAY_SIZE(build_list); i++)
{
switch (build_list[i].enum_idx)
{
case MENU_ENUM_LABEL_AUDIO_VOLUME:
if (!audio_mute_enable)
build_list[i].checked = true;
break;
case MENU_ENUM_LABEL_AUDIO_MIXER_VOLUME:
case MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS:
if (!audio_mixer_mute_enable)
build_list[i].checked = true;
break;
default:
break;
}
}

for (i = 0; i < ARRAY_SIZE(build_list); i++)
{
if (!build_list[i].checked && !include_everything)
continue;

if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
build_list[i].enum_idx, build_list[i].parse_type,
false) == 0)
count++;
}
}
{
bool audio_mute_enable = *audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE);
#if defined(HAVE_AUDIOMIXER)
bool audio_mixer_mute_enable = *audio_get_bool_ptr(AUDIO_ACTION_MIXER_MUTE_ENABLE);
#else
bool audio_mixer_mute_enable = true;
#endif
menu_displaylist_build_info_selective_t build_list[] = {
{MENU_ENUM_LABEL_AUDIO_OUTPUT_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_RESAMPLER_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_SYNCHRONIZATION_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_MIDI_SETTINGS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS, PARSE_ACTION, false },
{MENU_ENUM_LABEL_MENU_SOUNDS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_MIXER_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_FASTFORWARD_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_VOLUME, PARSE_ONLY_FLOAT, false },
{MENU_ENUM_LABEL_AUDIO_MIXER_VOLUME, PARSE_ONLY_FLOAT, false },
{MENU_ENUM_LABEL_SYSTEM_BGM_ENABLE, PARSE_ONLY_BOOL, true },
#if defined(HAVE_DSP_FILTER)
{MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, PARSE_ONLY_PATH, true },
#endif
};

for (i = 0; i < ARRAY_SIZE(build_list); i++)
{
switch (build_list[i].enum_idx)
{
case MENU_ENUM_LABEL_AUDIO_VOLUME:
if (!audio_mute_enable)
build_list[i].checked = true;
break;
case MENU_ENUM_LABEL_AUDIO_MIXER_VOLUME:
case MENU_ENUM_LABEL_AUDIO_MIXER_SETTINGS:
if (!audio_mixer_mute_enable)
build_list[i].checked = true;
break;
default:
break;
}
}

#ifdef HAVE_DSP_FILTER
for (i = 0; i < ARRAY_SIZE(build_list); i++)
{
if (!build_list[i].checked && !include_everything)
continue;

if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
build_list[i].enum_idx, build_list[i].parse_type,
false) == 0)
count++;
}
}

#if defined(HAVE_DSP_FILTER)
if (!string_is_empty(settings->paths.path_audio_dsp_plugin))
if (menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_AUDIO_DSP_PLUGIN_REMOVE),
Expand Down

0 comments on commit f505d62

Please sign in to comment.