filter/Volume: add volume_filter_prepare()

Circumvent filter_new() with a fake ConfigBlock.
This commit is contained in:
Max Kellermann 2017-08-07 18:23:13 +02:00
parent 04738636ca
commit 9250819b75
3 changed files with 12 additions and 7 deletions

View File

@ -78,6 +78,12 @@ const FilterPlugin volume_filter_plugin = {
volume_filter_init,
};
PreparedFilter *
volume_filter_prepare() noexcept
{
return new PreparedVolumeFilter();
}
unsigned
volume_filter_get(const Filter *_filter) noexcept
{

View File

@ -20,8 +20,12 @@
#ifndef MPD_VOLUME_FILTER_PLUGIN_HXX
#define MPD_VOLUME_FILTER_PLUGIN_HXX
class PreparedFilter;
class Filter;
PreparedFilter *
volume_filter_prepare() noexcept;
unsigned
volume_filter_get(const Filter *filter) noexcept;

View File

@ -33,6 +33,7 @@
#include "filter/plugins/AutoConvertFilterPlugin.hxx"
#include "filter/plugins/ReplayGainFilterPlugin.hxx"
#include "filter/plugins/ChainFilterPlugin.hxx"
#include "filter/plugins/VolumeFilterPlugin.hxx"
#include "config/ConfigError.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/Block.hxx"
@ -106,12 +107,6 @@ audio_output_mixer_type(const ConfigBlock &block) noexcept
"hardware"));
}
static PreparedFilter *
CreateVolumeFilter()
{
return filter_new(&volume_filter_plugin, ConfigBlock());
}
static Mixer *
audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
const ConfigBlock &block,
@ -144,7 +139,7 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
assert(mixer != nullptr);
filter_chain_append(filter_chain, "software_mixer",
ao.volume_filter.Set(CreateVolumeFilter()));
ao.volume_filter.Set(volume_filter_prepare()));
return mixer;
}