output/MultipleOutputs: move code to LoadOutputControl()

This commit is contained in:
Max Kellermann 2017-05-22 23:35:32 +02:00
parent 86d05e98e5
commit e5847f1ddf
1 changed files with 22 additions and 8 deletions

View File

@ -66,6 +66,18 @@ try {
throw;
}
static AudioOutputControl *
LoadOutputControl(EventLoop &event_loop,
const ReplayGainConfig &replay_gain_config,
MixerListener &mixer_listener,
AudioOutputClient &client, const ConfigBlock &block)
{
auto *output = LoadOutput(event_loop, replay_gain_config,
mixer_listener,
client, block);
return new AudioOutputControl(output);
}
void
MultipleOutputs::Configure(EventLoop &event_loop,
const ReplayGainConfig &replay_gain_config,
@ -73,23 +85,25 @@ MultipleOutputs::Configure(EventLoop &event_loop,
{
for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT);
param != nullptr; param = param->next) {
auto output = LoadOutput(event_loop, replay_gain_config,
mixer_listener,
client, *param);
auto *output = LoadOutputControl(event_loop,
replay_gain_config,
mixer_listener,
client, *param);
if (FindByName(output->GetName()) != nullptr)
throw FormatRuntimeError("output devices with identical "
"names: %s", output->GetName());
outputs.push_back(new AudioOutputControl(output));
outputs.push_back(output);
}
if (outputs.empty()) {
/* auto-detect device */
const ConfigBlock empty;
auto output = LoadOutput(event_loop, replay_gain_config,
mixer_listener,
client, empty);
outputs.push_back(new AudioOutputControl(output));
auto *output = LoadOutputControl(event_loop,
replay_gain_config,
mixer_listener,
client, empty);
outputs.push_back(output);
}
}