mixer: configure legacy mixer before the audio outputs
Reimplemented the legacy mixer configuration: copy the deprecated configuration values into the audio_output section. Don't configure the mixers twice (once for the audio_output, and a second time for the legacy values). This requires volume_init() to be called before initAudioDriver().
This commit is contained in:
parent
8695b94232
commit
188f9e663c
@ -246,9 +246,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
command_init();
|
command_init();
|
||||||
initialize_decoder_and_player();
|
initialize_decoder_and_player();
|
||||||
|
volume_init();
|
||||||
initAudioConfig();
|
initAudioConfig();
|
||||||
initAudioDriver();
|
initAudioDriver();
|
||||||
volume_init();
|
|
||||||
client_manager_init();
|
client_manager_init();
|
||||||
replay_gain_global_init();
|
replay_gain_global_init();
|
||||||
initNormalization();
|
initNormalization();
|
||||||
|
92
src/volume.c
92
src/volume.c
@ -47,32 +47,80 @@ void volume_finish(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/**
|
||||||
mixer_reconfigure(char *driver)
|
* Finds the first audio_output configuration section with the
|
||||||
|
* specified type.
|
||||||
|
*/
|
||||||
|
static struct config_param *
|
||||||
|
find_output_config(const char *type)
|
||||||
{
|
{
|
||||||
struct config_param *newparam, *param;
|
struct config_param *param = NULL;
|
||||||
|
|
||||||
//create parameter list
|
while ((param = config_get_next_param(CONF_AUDIO_OUTPUT,
|
||||||
newparam = newConfigParam(NULL, -1);
|
param)) != NULL) {
|
||||||
|
const char *param_type =
|
||||||
|
config_get_block_string(param, "type", NULL);
|
||||||
|
if (param_type != NULL && strcmp(param_type, type) == 0)
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
param = config_get_param(CONF_MIXER_DEVICE);
|
return NULL;
|
||||||
if (param) {
|
}
|
||||||
g_warning("deprecated option mixer_device found, translating to %s config section\n", driver);
|
|
||||||
addBlockParam(newparam, "mixer_device", param->value, -1);
|
/**
|
||||||
|
* Copy a (top-level) legacy mixer configuration parameter to the
|
||||||
|
* audio_output section.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
mixer_copy_legacy_param(const char *type, const char *name)
|
||||||
|
{
|
||||||
|
const struct config_param *param;
|
||||||
|
struct config_param *output;
|
||||||
|
const struct block_param *bp;
|
||||||
|
|
||||||
|
/* see if the deprecated configuration exists */
|
||||||
|
|
||||||
|
param = config_get_param(name);
|
||||||
|
if (param == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_warning("deprecated option '%s' found, moving to '%s' audio output",
|
||||||
|
name, type);
|
||||||
|
|
||||||
|
/* determine the configuration section */
|
||||||
|
|
||||||
|
output = find_output_config(type);
|
||||||
|
if (output == NULL) {
|
||||||
|
/* if there is no output configuration at all, create
|
||||||
|
a new and empty configuration section for the
|
||||||
|
legacy mixer */
|
||||||
|
|
||||||
|
if (config_get_next_param(CONF_AUDIO_OUTPUT, NULL) != NULL)
|
||||||
|
/* there is an audio_output configuration, but
|
||||||
|
it does not match the mixer_type setting */
|
||||||
|
g_error("no '%s' audio output found", type);
|
||||||
|
|
||||||
|
output = newConfigParam(NULL, param->line);
|
||||||
|
addBlockParam(output, "type", type, param->line);
|
||||||
|
addBlockParam(output, "name", type, param->line);
|
||||||
|
config_add_param(CONF_AUDIO_OUTPUT, output);
|
||||||
}
|
}
|
||||||
param = config_get_param(CONF_MIXER_CONTROL);
|
|
||||||
if (param) {
|
bp = getBlockParam(output, name);
|
||||||
g_warning("deprecated option mixer_control found, translating to %s config section\n", driver);
|
if (bp != NULL)
|
||||||
addBlockParam(newparam, "mixer_control", param->value, -1);
|
g_error("the '%s' audio output already has a '%s' setting",
|
||||||
}
|
type, name);
|
||||||
if (newparam->num_block_params > 0) {
|
|
||||||
//call configure method of corrensponding mixer
|
/* duplicate the parameter in the configuration section */
|
||||||
if (!mixer_configure_legacy(driver, newparam)) {
|
|
||||||
g_error("Using mixer_type '%s' with not enabled %s output", driver, driver);
|
addBlockParam(output, name, param->value, param->line);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//free parameter list
|
static void
|
||||||
config_param_free(newparam, NULL);
|
mixer_reconfigure(const char *type)
|
||||||
|
{
|
||||||
|
mixer_copy_legacy_param(type, CONF_MIXER_DEVICE);
|
||||||
|
mixer_copy_legacy_param(type, CONF_MIXER_CONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void volume_init(void)
|
void volume_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user