filter/Plugin: return std::unique_ptr<PreparedFilter>
This commit is contained in:
@@ -62,13 +62,11 @@ class PreparedAutoConvertFilter final : public PreparedFilter {
|
||||
/**
|
||||
* The underlying filter.
|
||||
*/
|
||||
PreparedFilter *const filter;
|
||||
std::unique_ptr<PreparedFilter> filter;
|
||||
|
||||
public:
|
||||
PreparedAutoConvertFilter(PreparedFilter *_filter):filter(_filter) {}
|
||||
~PreparedAutoConvertFilter() {
|
||||
delete filter;
|
||||
}
|
||||
PreparedAutoConvertFilter(std::unique_ptr<PreparedFilter> _filter) noexcept
|
||||
:filter(std::move(_filter)) {}
|
||||
|
||||
Filter *Open(AudioFormat &af) override;
|
||||
};
|
||||
@@ -106,8 +104,8 @@ AutoConvertFilter::FilterPCM(ConstBuffer<void> src)
|
||||
return filter->FilterPCM(src);
|
||||
}
|
||||
|
||||
PreparedFilter *
|
||||
autoconvert_filter_new(PreparedFilter *filter)
|
||||
std::unique_ptr<PreparedFilter>
|
||||
autoconvert_filter_new(std::unique_ptr<PreparedFilter> filter) noexcept
|
||||
{
|
||||
return new PreparedAutoConvertFilter(filter);
|
||||
return std::make_unique<PreparedAutoConvertFilter>(std::move(filter));
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#ifndef MPD_AUTOCONVERT_FILTER_PLUGIN_HXX
|
||||
#define MPD_AUTOCONVERT_FILTER_PLUGIN_HXX
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PreparedFilter;
|
||||
|
||||
/**
|
||||
@@ -28,7 +30,7 @@ class PreparedFilter;
|
||||
* requests a different format, it automatically creates a
|
||||
* convert_filter.
|
||||
*/
|
||||
PreparedFilter *
|
||||
autoconvert_filter_new(PreparedFilter *filter);
|
||||
std::unique_ptr<PreparedFilter>
|
||||
autoconvert_filter_new(std::unique_ptr<PreparedFilter> filter) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -67,13 +67,11 @@ public:
|
||||
class PreparedChainFilter final : public PreparedFilter {
|
||||
struct Child {
|
||||
const char *name;
|
||||
PreparedFilter *filter;
|
||||
std::unique_ptr<PreparedFilter> filter;
|
||||
|
||||
Child(const char *_name, PreparedFilter *_filter)
|
||||
:name(_name), filter(_filter) {}
|
||||
~Child() {
|
||||
delete filter;
|
||||
}
|
||||
Child(const char *_name,
|
||||
std::unique_ptr<PreparedFilter> _filter)
|
||||
:name(_name), filter(std::move(_filter)) {}
|
||||
|
||||
Child(const Child &) = delete;
|
||||
Child &operator=(const Child &) = delete;
|
||||
@@ -84,8 +82,9 @@ class PreparedChainFilter final : public PreparedFilter {
|
||||
std::list<Child> children;
|
||||
|
||||
public:
|
||||
void Append(const char *name, PreparedFilter *filter) {
|
||||
children.emplace_back(name, filter);
|
||||
void Append(const char *name,
|
||||
std::unique_ptr<PreparedFilter> filter) noexcept {
|
||||
children.emplace_back(name, std::move(filter));
|
||||
}
|
||||
|
||||
/* virtual methods from class PreparedFilter */
|
||||
@@ -143,17 +142,17 @@ ChainFilter::FilterPCM(ConstBuffer<void> src)
|
||||
return src;
|
||||
}
|
||||
|
||||
PreparedFilter *
|
||||
filter_chain_new(void)
|
||||
std::unique_ptr<PreparedFilter>
|
||||
filter_chain_new() noexcept
|
||||
{
|
||||
return new PreparedChainFilter();
|
||||
return std::make_unique<PreparedChainFilter>();
|
||||
}
|
||||
|
||||
void
|
||||
filter_chain_append(PreparedFilter &_chain, const char *name,
|
||||
PreparedFilter *filter)
|
||||
std::unique_ptr<PreparedFilter> filter) noexcept
|
||||
{
|
||||
PreparedChainFilter &chain = (PreparedChainFilter &)_chain;
|
||||
|
||||
chain.Append(name, filter);
|
||||
chain.Append(name, std::move(filter));
|
||||
}
|
||||
|
@@ -27,13 +27,15 @@
|
||||
#ifndef MPD_FILTER_CHAIN_HXX
|
||||
#define MPD_FILTER_CHAIN_HXX
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PreparedFilter;
|
||||
|
||||
/**
|
||||
* Creates a new filter chain.
|
||||
*/
|
||||
PreparedFilter *
|
||||
filter_chain_new();
|
||||
std::unique_ptr<PreparedFilter>
|
||||
filter_chain_new() noexcept;
|
||||
|
||||
/**
|
||||
* Appends a new filter at the end of the filter chain. You must call
|
||||
@@ -44,6 +46,6 @@ filter_chain_new();
|
||||
*/
|
||||
void
|
||||
filter_chain_append(PreparedFilter &chain, const char *name,
|
||||
PreparedFilter *filter);
|
||||
std::unique_ptr<PreparedFilter> filter) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -119,10 +119,10 @@ ConvertFilter::FilterPCM(ConstBuffer<void> src)
|
||||
return state.Convert(src);
|
||||
}
|
||||
|
||||
PreparedFilter *
|
||||
std::unique_ptr<PreparedFilter>
|
||||
convert_filter_prepare() noexcept
|
||||
{
|
||||
return new PreparedConvertFilter();
|
||||
return std::make_unique<PreparedConvertFilter>();
|
||||
}
|
||||
|
||||
Filter *
|
||||
|
@@ -20,11 +20,13 @@
|
||||
#ifndef MPD_CONVERT_FILTER_PLUGIN_HXX
|
||||
#define MPD_CONVERT_FILTER_PLUGIN_HXX
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PreparedFilter;
|
||||
class Filter;
|
||||
struct AudioFormat;
|
||||
|
||||
PreparedFilter *
|
||||
std::unique_ptr<PreparedFilter>
|
||||
convert_filter_prepare() noexcept;
|
||||
|
||||
Filter *
|
||||
|
@@ -53,10 +53,10 @@ public:
|
||||
Filter *Open(AudioFormat &af) override;
|
||||
};
|
||||
|
||||
static PreparedFilter *
|
||||
static std::unique_ptr<PreparedFilter>
|
||||
normalize_filter_init(gcc_unused const ConfigBlock &block)
|
||||
{
|
||||
return new PreparedNormalizeFilter();
|
||||
return std::make_unique<PreparedNormalizeFilter>();
|
||||
}
|
||||
|
||||
Filter *
|
||||
@@ -82,8 +82,8 @@ const FilterPlugin normalize_filter_plugin = {
|
||||
normalize_filter_init,
|
||||
};
|
||||
|
||||
PreparedFilter *
|
||||
std::unique_ptr<PreparedFilter>
|
||||
normalize_filter_prepare() noexcept
|
||||
{
|
||||
return new PreparedNormalizeFilter();
|
||||
return std::make_unique<PreparedNormalizeFilter>();
|
||||
}
|
||||
|
@@ -20,11 +20,13 @@
|
||||
#ifndef MPD_NORMALIZE_FILTER_PLUGIN_HXX
|
||||
#define MPD_NORMALIZE_FILTER_PLUGIN_HXX
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PreparedFilter;
|
||||
class Filter;
|
||||
struct AudioFormat;
|
||||
|
||||
PreparedFilter *
|
||||
std::unique_ptr<PreparedFilter>
|
||||
normalize_filter_prepare() noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -48,10 +48,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static PreparedFilter *
|
||||
static std::unique_ptr<PreparedFilter>
|
||||
null_filter_init(gcc_unused const ConfigBlock &block)
|
||||
{
|
||||
return new PreparedNullFilter();
|
||||
return std::make_unique<PreparedNullFilter>();
|
||||
}
|
||||
|
||||
const FilterPlugin null_filter_plugin = {
|
||||
|
@@ -171,10 +171,10 @@ ReplayGainFilter::Update()
|
||||
pv.SetVolume(volume);
|
||||
}
|
||||
|
||||
PreparedFilter *
|
||||
NewReplayGainFilter(const ReplayGainConfig &config)
|
||||
std::unique_ptr<PreparedFilter>
|
||||
NewReplayGainFilter(const ReplayGainConfig &config) noexcept
|
||||
{
|
||||
return new PreparedReplayGainFilter(config);
|
||||
return std::make_unique<PreparedReplayGainFilter>(config);
|
||||
}
|
||||
|
||||
Filter *
|
||||
|
@@ -22,14 +22,16 @@
|
||||
|
||||
#include "ReplayGainMode.hxx"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class Filter;
|
||||
class PreparedFilter;
|
||||
class Mixer;
|
||||
struct ReplayGainConfig;
|
||||
struct ReplayGainInfo;
|
||||
|
||||
PreparedFilter *
|
||||
NewReplayGainFilter(const ReplayGainConfig &config);
|
||||
std::unique_ptr<PreparedFilter>
|
||||
NewReplayGainFilter(const ReplayGainConfig &config) noexcept;
|
||||
|
||||
/**
|
||||
* Enables or disables the hardware mixer for applying replay gain.
|
||||
|
@@ -196,10 +196,10 @@ PreparedRouteFilter::PreparedRouteFilter(const ConfigBlock &block)
|
||||
}
|
||||
}
|
||||
|
||||
static PreparedFilter *
|
||||
static std::unique_ptr<PreparedFilter>
|
||||
route_filter_init(const ConfigBlock &block)
|
||||
{
|
||||
return new PreparedRouteFilter(block);
|
||||
return std::make_unique<PreparedRouteFilter>(block);
|
||||
}
|
||||
|
||||
RouteFilter::RouteFilter(const AudioFormat &audio_format,
|
||||
|
@@ -65,10 +65,10 @@ VolumeFilter::FilterPCM(ConstBuffer<void> src)
|
||||
return pv.Apply(src);
|
||||
}
|
||||
|
||||
PreparedFilter *
|
||||
std::unique_ptr<PreparedFilter>
|
||||
volume_filter_prepare() noexcept
|
||||
{
|
||||
return new PreparedVolumeFilter();
|
||||
return std::make_unique<PreparedVolumeFilter>();
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
@@ -20,10 +20,12 @@
|
||||
#ifndef MPD_VOLUME_FILTER_PLUGIN_HXX
|
||||
#define MPD_VOLUME_FILTER_PLUGIN_HXX
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PreparedFilter;
|
||||
class Filter;
|
||||
|
||||
PreparedFilter *
|
||||
std::unique_ptr<PreparedFilter>
|
||||
volume_filter_prepare() noexcept;
|
||||
|
||||
unsigned
|
||||
|
Reference in New Issue
Block a user