aboutsummaryrefslogtreecommitdiff
path: root/src/FilterInternal.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-02-01 18:40:36 +0100
committerMax Kellermann <max@duempel.org>2013-02-02 09:34:07 +0100
commita9ce0218c1879a752c9d9ec6ef21fcf44eab51ab (patch)
treef30de05c9f0a45906d31d2d4a3dad2281fe8d49c /src/FilterInternal.hxx
parent7bb5a960fde46363adf888db5b05b7b883d2b16b (diff)
FilterInternal: convert struct filter to a OO interface
Diffstat (limited to 'src/FilterInternal.hxx')
-rw-r--r--src/FilterInternal.hxx49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/FilterInternal.hxx b/src/FilterInternal.hxx
index 7ffcec33..cdc2d0ea 100644
--- a/src/FilterInternal.hxx
+++ b/src/FilterInternal.hxx
@@ -25,14 +25,47 @@
#ifndef MPD_FILTER_INTERNAL_HXX
#define MPD_FILTER_INTERNAL_HXX
-struct filter {
- const struct filter_plugin *plugin;
-};
+struct audio_format;
+
+class Filter {
+public:
+ virtual ~Filter() {}
+
+ /**
+ * Opens the filter, preparing it for FilterPCM().
+ *
+ * @param filter the filter object
+ * @param audio_format the audio format of incoming data; the
+ * plugin may modify the object to enforce another input
+ * format
+ * @param error location to store the error occurring, or NULL
+ * to ignore errors.
+ * @return the format of outgoing data
+ */
+ virtual const audio_format *Open(audio_format &af,
+ GError **error_r) = 0;
-static inline void
-filter_init(struct filter *filter, const struct filter_plugin *plugin)
-{
- filter->plugin = plugin;
-}
+ /**
+ * Closes the filter. After that, you may call Open() again.
+ */
+ virtual void Close() = 0;
+
+ /**
+ * Filters a block of PCM data.
+ *
+ * @param filter the filter object
+ * @param src the input buffer
+ * @param src_size the size of #src_buffer in bytes
+ * @param dest_size_r the size of the returned buffer
+ * @param error location to store the error occurring, or NULL
+ * to ignore errors.
+ * @return the destination buffer on success (will be
+ * invalidated by filter_close() or filter_filter()), NULL on
+ * error
+ */
+ virtual const void *FilterPCM(const void *src, size_t src_size,
+ size_t *dest_size_r,
+ GError **error_r) = 0;
+};
#endif