summaryrefslogtreecommitdiff
path: root/src/filter
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-02-01 17:47:09 +0100
committerMax Kellermann <max@duempel.org>2013-02-01 17:47:09 +0100
commit3894450b10baeaa17c871cb5dc1a0961e0726fae (patch)
tree66d8b5fa85eb70e13ab0826345103505ab694d58 /src/filter
parentec07f6ec835abccda5ff7bf346645739fb5e116a (diff)
filter: convert to C++
Diffstat (limited to 'src/filter')
-rw-r--r--src/filter/AutoConvertFilterPlugin.cxx6
-rw-r--r--src/filter/ChainFilterPlugin.cxx (renamed from src/filter/chain_filter_plugin.c)59
-rw-r--r--src/filter/ChainFilterPlugin.hxx (renamed from src/filter/chain_filter_plugin.h)6
-rw-r--r--src/filter/ConvertFilterPlugin.cxx6
-rw-r--r--src/filter/NormalizeFilterPlugin.cxx (renamed from src/filter/normalize_filter_plugin.c)23
-rw-r--r--src/filter/NullFilterPlugin.cxx (renamed from src/filter/null_filter_plugin.c)20
-rw-r--r--src/filter/ReplayGainFilterPlugin.cxx6
-rw-r--r--src/filter/RouteFilterPlugin.cxx (renamed from src/filter/route_filter_plugin.c)27
-rw-r--r--src/filter/VolumeFilterPlugin.cxx6
9 files changed, 79 insertions, 80 deletions
diff --git a/src/filter/AutoConvertFilterPlugin.cxx b/src/filter/AutoConvertFilterPlugin.cxx
index 3a8c087ba..2a183b579 100644
--- a/src/filter/AutoConvertFilterPlugin.cxx
+++ b/src/filter/AutoConvertFilterPlugin.cxx
@@ -20,9 +20,9 @@
#include "config.h"
#include "AutoConvertFilterPlugin.hxx"
#include "ConvertFilterPlugin.hxx"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "audio_format.h"
#include <assert.h>
diff --git a/src/filter/chain_filter_plugin.c b/src/filter/ChainFilterPlugin.cxx
index 0788b6751..51eb4b6f6 100644
--- a/src/filter/chain_filter_plugin.c
+++ b/src/filter/ChainFilterPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,22 +18,26 @@
*/
#include "config.h"
+#include "ChainFilterPlugin.hxx"
#include "conf.h"
-#include "filter/chain_filter_plugin.h"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "audio_format.h"
#include <glib.h>
#include <assert.h>
-struct filter_chain {
+struct ChainFilter {
/** the base class */
struct filter base;
GSList *children;
+
+ ChainFilter():children(nullptr) {
+ filter_init(&base, &chain_filter_plugin);
+ }
};
static inline GQuark
@@ -46,10 +50,7 @@ static struct filter *
chain_filter_init(G_GNUC_UNUSED const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
{
- struct filter_chain *chain = g_new(struct filter_chain, 1);
-
- filter_init(&chain->base, &chain_filter_plugin);
- chain->children = NULL;
+ ChainFilter *chain = new ChainFilter();
return &chain->base;
}
@@ -57,7 +58,7 @@ chain_filter_init(G_GNUC_UNUSED const struct config_param *param,
static void
chain_free_child(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- struct filter *filter = data;
+ struct filter *filter = (struct filter *)data;
filter_free(filter);
}
@@ -65,12 +66,12 @@ chain_free_child(gpointer data, G_GNUC_UNUSED gpointer user_data)
static void
chain_filter_finish(struct filter *_filter)
{
- struct filter_chain *chain = (struct filter_chain *)_filter;
+ ChainFilter *chain = (ChainFilter *)_filter;
g_slist_foreach(chain->children, chain_free_child, NULL);
g_slist_free(chain->children);
- g_free(chain);
+ delete chain;
}
/**
@@ -78,10 +79,9 @@ chain_filter_finish(struct filter *_filter)
* itself is not closed.
*/
static void
-chain_close_until(struct filter_chain *chain, const struct filter *until)
+chain_close_until(ChainFilter *chain, const struct filter *until)
{
GSList *i = chain->children;
- struct filter *filter;
while (true) {
/* this assertion fails if #until does not exist
@@ -93,7 +93,7 @@ chain_close_until(struct filter_chain *chain, const struct filter *until)
break;
/* close this filter */
- filter = i->data;
+ struct filter *filter = (struct filter *)i->data;
filter_close(filter);
i = g_slist_next(i);
@@ -130,11 +130,11 @@ static const struct audio_format *
chain_filter_open(struct filter *_filter, struct audio_format *in_audio_format,
GError **error_r)
{
- struct filter_chain *chain = (struct filter_chain *)_filter;
+ ChainFilter *chain = (ChainFilter *)_filter;
const struct audio_format *audio_format = in_audio_format;
for (GSList *i = chain->children; i != NULL; i = g_slist_next(i)) {
- struct filter *filter = i->data;
+ struct filter *filter = (struct filter *)i->data;
audio_format = chain_open_child(filter, audio_format, error_r);
if (audio_format == NULL) {
@@ -151,7 +151,7 @@ chain_filter_open(struct filter *_filter, struct audio_format *in_audio_format,
static void
chain_close_child(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- struct filter *filter = data;
+ struct filter *filter = (struct filter *)data;
filter_close(filter);
}
@@ -159,7 +159,7 @@ chain_close_child(gpointer data, G_GNUC_UNUSED gpointer user_data)
static void
chain_filter_close(struct filter *_filter)
{
- struct filter_chain *chain = (struct filter_chain *)_filter;
+ ChainFilter *chain = (ChainFilter *)_filter;
g_slist_foreach(chain->children, chain_close_child, NULL);
}
@@ -169,10 +169,10 @@ chain_filter_filter(struct filter *_filter,
const void *src, size_t src_size,
size_t *dest_size_r, GError **error_r)
{
- struct filter_chain *chain = (struct filter_chain *)_filter;
+ ChainFilter *chain = (ChainFilter *)_filter;
for (GSList *i = chain->children; i != NULL; i = g_slist_next(i)) {
- struct filter *filter = i->data;
+ struct filter *filter = (struct filter *)i->data;
/* feed the output of the previous filter as input
into the current one */
@@ -187,12 +187,12 @@ chain_filter_filter(struct filter *_filter,
}
const struct filter_plugin chain_filter_plugin = {
- .name = "chain",
- .init = chain_filter_init,
- .finish = chain_filter_finish,
- .open = chain_filter_open,
- .close = chain_filter_close,
- .filter = chain_filter_filter,
+ "chain",
+ chain_filter_init,
+ chain_filter_finish,
+ chain_filter_open,
+ chain_filter_close,
+ chain_filter_filter,
};
struct filter *
@@ -208,8 +208,7 @@ filter_chain_new(void)
void
filter_chain_append(struct filter *_chain, struct filter *filter)
{
- struct filter_chain *chain = (struct filter_chain *)_chain;
+ ChainFilter *chain = (ChainFilter *)_chain;
chain->children = g_slist_append(chain->children, filter);
}
-
diff --git a/src/filter/chain_filter_plugin.h b/src/filter/ChainFilterPlugin.hxx
index 1dba46667..242d29dae 100644
--- a/src/filter/chain_filter_plugin.h
+++ b/src/filter/ChainFilterPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -24,8 +24,8 @@
* output to the next one.
*/
-#ifndef MPD_FILTER_CHAIN_H
-#define MPD_FILTER_CHAIN_H
+#ifndef MPD_FILTER_CHAIN_HXX
+#define MPD_FILTER_CHAIN_HXX
struct filter;
diff --git a/src/filter/ConvertFilterPlugin.cxx b/src/filter/ConvertFilterPlugin.cxx
index 6a5acd707..b07cf80f1 100644
--- a/src/filter/ConvertFilterPlugin.cxx
+++ b/src/filter/ConvertFilterPlugin.cxx
@@ -19,9 +19,9 @@
#include "config.h"
#include "ConvertFilterPlugin.hxx"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "conf.h"
#include "PcmConvert.hxx"
#include "util/Manual.hxx"
diff --git a/src/filter/normalize_filter_plugin.c b/src/filter/NormalizeFilterPlugin.cxx
index 2151482e4..0dc36c5bc 100644
--- a/src/filter/normalize_filter_plugin.c
+++ b/src/filter/NormalizeFilterPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,9 +18,9 @@
*/
#include "config.h"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "pcm_buffer.h"
#include "audio_format.h"
#include "AudioCompress/compress.h"
@@ -90,9 +90,8 @@ normalize_filter_filter(struct filter *_filter,
G_GNUC_UNUSED GError **error_r)
{
struct normalize_filter *filter = (struct normalize_filter *)_filter;
- void *dest;
- dest = pcm_buffer_get(&filter->buffer, src_size);
+ int16_t *dest = (int16_t *)pcm_buffer_get(&filter->buffer, src_size);
memcpy(dest, src, src_size);
@@ -103,10 +102,10 @@ normalize_filter_filter(struct filter *_filter,
}
const struct filter_plugin normalize_filter_plugin = {
- .name = "normalize",
- .init = normalize_filter_init,
- .finish = normalize_filter_finish,
- .open = normalize_filter_open,
- .close = normalize_filter_close,
- .filter = normalize_filter_filter,
+ "normalize",
+ normalize_filter_init,
+ normalize_filter_finish,
+ normalize_filter_open,
+ normalize_filter_close,
+ normalize_filter_filter,
};
diff --git a/src/filter/null_filter_plugin.c b/src/filter/NullFilterPlugin.cxx
index 7728c55bf..9c1a9c959 100644
--- a/src/filter/null_filter_plugin.c
+++ b/src/filter/NullFilterPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -25,9 +25,9 @@
*/
#include "config.h"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include <glib.h>
#include <assert.h>
@@ -85,10 +85,10 @@ null_filter_filter(struct filter *_filter,
}
const struct filter_plugin null_filter_plugin = {
- .name = "null",
- .init = null_filter_init,
- .finish = null_filter_finish,
- .open = null_filter_open,
- .close = null_filter_close,
- .filter = null_filter_filter,
+ "null",
+ null_filter_init,
+ null_filter_finish,
+ null_filter_open,
+ null_filter_close,
+ null_filter_filter,
};
diff --git a/src/filter/ReplayGainFilterPlugin.cxx b/src/filter/ReplayGainFilterPlugin.cxx
index 9fb412be7..856213530 100644
--- a/src/filter/ReplayGainFilterPlugin.cxx
+++ b/src/filter/ReplayGainFilterPlugin.cxx
@@ -19,9 +19,9 @@
#include "config.h"
#include "ReplayGainFilterPlugin.hxx"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "audio_format.h"
#include "replay_gain_info.h"
#include "replay_gain_config.h"
diff --git a/src/filter/route_filter_plugin.c b/src/filter/RouteFilterPlugin.cxx
index c0ecbd9c8..35f8c5c76 100644
--- a/src/filter/route_filter_plugin.c
+++ b/src/filter/RouteFilterPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -44,9 +44,9 @@
#include "ConfigQuark.hxx"
#include "audio_format.h"
#include "audio_check.h"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "pcm_buffer.h"
#include <assert.h>
@@ -188,7 +188,7 @@ route_filter_parse(const struct config_param *param,
}
// Allocate a map of "copy nothing to me"
- filter->sources =
+ filter->sources = (signed char *)
g_malloc(filter->min_output_channels * sizeof(signed char));
for (int i=0; i<filter->min_output_channels; ++i)
@@ -295,14 +295,15 @@ route_filter_filter(struct filter *_filter,
audio_format_sample_size(&filter->input_format);
// A moving pointer that always refers to channel 0 in the input, at the currently handled frame
- const uint8_t *base_source = src;
+ const uint8_t *base_source = (const uint8_t *)src;
// A moving pointer that always refers to the currently filled channel of the currently handled frame, in the output
uint8_t *chan_destination;
// Grow our reusable buffer, if needed, and set the moving pointer
*dest_size_r = number_of_frames * filter->output_frame_size;
- chan_destination = pcm_buffer_get(&filter->output_buffer, *dest_size_r);
+ chan_destination = (uint8_t *)
+ pcm_buffer_get(&filter->output_buffer, *dest_size_r);
// Perform our copy operations, with N input channels and M output channels
@@ -340,10 +341,10 @@ route_filter_filter(struct filter *_filter,
}
const struct filter_plugin route_filter_plugin = {
- .name = "route",
- .init = route_filter_init,
- .finish = route_filter_finish,
- .open = route_filter_open,
- .close = route_filter_close,
- .filter = route_filter_filter,
+ "route",
+ route_filter_init,
+ route_filter_finish,
+ route_filter_open,
+ route_filter_close,
+ route_filter_filter,
};
diff --git a/src/filter/VolumeFilterPlugin.cxx b/src/filter/VolumeFilterPlugin.cxx
index 5066ebbfa..f1a1f4784 100644
--- a/src/filter/VolumeFilterPlugin.cxx
+++ b/src/filter/VolumeFilterPlugin.cxx
@@ -19,9 +19,9 @@
#include "config.h"
#include "VolumeFilterPlugin.hxx"
-#include "filter_plugin.h"
-#include "filter_internal.h"
-#include "filter_registry.h"
+#include "FilterPlugin.hxx"
+#include "FilterInternal.hxx"
+#include "FilterRegistry.hxx"
#include "conf.h"
#include "pcm_buffer.h"
#include "PcmVolume.hxx"