sound: save cfg master volume when non-default

This commit is contained in:
hap 2022-09-29 13:22:35 +02:00
parent c67bcb4b55
commit d1cefdfed0

View File

@ -1383,6 +1383,10 @@ void sound_manager::config_load(config_type cfg_type, config_level cfg_level, ut
if ((cfg_type != config_type::SYSTEM) || !parentnode)
return;
// master volume attenuation
if (util::xml::data_node const *node = parentnode->get_child("attenuation"))
set_attenuation(std::clamp(int(node->get_attribute_int("value", 0)), -32, 0));
// iterate over channel nodes
for (util::xml::data_node const *channelnode = parentnode->get_child("channel"); channelnode != nullptr; channelnode = channelnode->get_next_sibling("channel"))
{
@ -1409,6 +1413,13 @@ void sound_manager::config_save(config_type cfg_type, util::xml::data_node *pare
if (cfg_type != config_type::SYSTEM)
return;
// master volume attenuation
if (m_attenuation != machine().options().volume())
{
if (util::xml::data_node *const node = parentnode->add_child("attenuation", nullptr))
node->set_attribute_int("value", m_attenuation);
}
// iterate over mixer channels
for (int mixernum = 0; ; mixernum++)
{