summaryrefslogtreecommitdiff
path: root/src/filter/Observer.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-12-27 09:17:15 +0100
committerMax Kellermann <max@musicpd.org>2017-12-27 11:39:01 +0100
commite2621d5e44be0da281edd7d6906a085360959fde (patch)
tree6c4a5fae2488b31f70b01c04809c2e1ab18b9028 /src/filter/Observer.cxx
parent0e3ff12dd35bce20bc1ed1fba4a148de572e0c8c (diff)
filter/Plugin: return std::unique_ptr<PreparedFilter>
Diffstat (limited to 'src/filter/Observer.cxx')
-rw-r--r--src/filter/Observer.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/filter/Observer.cxx b/src/filter/Observer.cxx
index 5d6602d46..706abd8b7 100644
--- a/src/filter/Observer.cxx
+++ b/src/filter/Observer.cxx
@@ -27,21 +27,20 @@
class FilterObserver::PreparedProxy final : public PreparedFilter {
FilterObserver &observer;
- PreparedFilter *const prepared_filter;
+ std::unique_ptr<PreparedFilter> prepared_filter;
Proxy *child = nullptr;
public:
PreparedProxy(FilterObserver &_observer,
- PreparedFilter *_prepared_filter)
+ std::unique_ptr<PreparedFilter> _prepared_filter)
:observer(_observer),
- prepared_filter(_prepared_filter) {}
+ prepared_filter(std::move(_prepared_filter)) {}
~PreparedProxy() {
assert(child == nullptr);
assert(observer.proxy == this);
observer.proxy = nullptr;
- delete prepared_filter;
}
void Clear(gcc_unused Proxy *_child) {
@@ -95,12 +94,14 @@ FilterObserver::PreparedProxy::Open(AudioFormat &af)
return child = new Proxy(*this, f);
}
-PreparedFilter *
-FilterObserver::Set(PreparedFilter *pf)
+std::unique_ptr<PreparedFilter>
+FilterObserver::Set(std::unique_ptr<PreparedFilter> pf)
{
assert(proxy == nullptr);
- return proxy = new PreparedProxy(*this, pf);
+ auto p = std::make_unique<PreparedProxy>(*this, std::move(pf));
+ proxy = p.get();
+ return p;
}
Filter *