output/multiple: add "client" field, replacing the "client" parameter

By eliminating GetAnyClient(), we can have instances with no outputs
at all.
This commit is contained in:
Max Kellermann 2020-01-20 14:51:06 +01:00
parent ff2e584bde
commit 4df98466df
5 changed files with 14 additions and 22 deletions

View File

@ -447,8 +447,7 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
for (auto &partition : instance.partitions) {
partition.outputs.Configure(instance.rtio_thread.GetEventLoop(),
raw_config,
config.replay_gain,
partition.pc);
config.replay_gain);
partition.UpdateEffectiveReplayGainMode();
}

View File

@ -43,7 +43,7 @@ Partition::Partition(Instance &_instance,
idle_monitor(instance.event_loop, BIND_THIS_METHOD(OnIdleMonitor)),
global_events(instance.event_loop, BIND_THIS_METHOD(OnGlobalEvent)),
playlist(max_length, *this),
outputs(*this),
outputs(pc, *this),
pc(*this, outputs,
instance.input_cache.get(),
buffer_chunks,

View File

@ -106,8 +106,7 @@ handle_newpartition(Client &client, Request request, Response &response)
ReplayGainConfig());
auto &partition = instance.partitions.back();
partition.outputs.AddNullOutput(instance.io_thread.GetEventLoop(),
ReplayGainConfig(),
partition.pc);
ReplayGainConfig());
partition.UpdateEffectiveReplayGainMode();
instance.EmitIdle(IDLE_PARTITION);

View File

@ -35,8 +35,9 @@
#include <assert.h>
#include <string.h>
MultipleOutputs::MultipleOutputs(MixerListener &_mixer_listener) noexcept
:mixer_listener(_mixer_listener)
MultipleOutputs::MultipleOutputs(AudioOutputClient &_client,
MixerListener &_mixer_listener) noexcept
:client(_client), mixer_listener(_mixer_listener)
{
}
@ -86,8 +87,7 @@ LoadOutputControl(EventLoop &event_loop,
void
MultipleOutputs::Configure(EventLoop &event_loop,
const ConfigData &config,
const ReplayGainConfig &replay_gain_config,
AudioOutputClient &client)
const ReplayGainConfig &replay_gain_config)
{
const AudioOutputDefaults defaults(config);
FilterFactory filter_factory(config);
@ -119,8 +119,7 @@ MultipleOutputs::Configure(EventLoop &event_loop,
void
MultipleOutputs::AddNullOutput(EventLoop &event_loop,
const ReplayGainConfig &replay_gain_config,
AudioOutputClient &client)
const ReplayGainConfig &replay_gain_config)
{
const AudioOutputDefaults defaults;
@ -147,8 +146,6 @@ void
MultipleOutputs::Add(std::unique_ptr<FilteredAudioOutput> output,
bool enable) noexcept
{
auto &client = GetAnyClient();
// TODO: this operation needs to be protected with a mutex
outputs.emplace_back(std::make_unique<AudioOutputControl>(std::move(output),
client));

View File

@ -45,6 +45,8 @@ struct ReplayGainConfig;
* keeps them synchronized.
*/
class MultipleOutputs final : public PlayerOutputs {
AudioOutputClient &client;
MixerListener &mixer_listener;
std::vector<std::unique_ptr<AudioOutputControl>> outputs;
@ -68,17 +70,16 @@ public:
* Load audio outputs from the configuration file and
* initialize them.
*/
MultipleOutputs(MixerListener &_mixer_listener) noexcept;
MultipleOutputs(AudioOutputClient &_client,
MixerListener &_mixer_listener) noexcept;
~MultipleOutputs() noexcept;
void Configure(EventLoop &event_loop,
const ConfigData &config,
const ReplayGainConfig &replay_gain_config,
AudioOutputClient &client);
const ReplayGainConfig &replay_gain_config);
void AddNullOutput(EventLoop &event_loop,
const ReplayGainConfig &replay_gain_config,
AudioOutputClient &client);
const ReplayGainConfig &replay_gain_config);
/**
* Returns the total number of audio output devices, including
@ -156,10 +157,6 @@ public:
void SetSoftwareVolume(unsigned volume) noexcept;
private:
AudioOutputClient &GetAnyClient() noexcept {
return outputs.front()->GetClient();
}
/**
* Was Open() called successfully?
*