diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile.am | 8 | ||||
-rw-r--r-- | src/OutputInit.cxx | 2 | ||||
-rw-r--r-- | src/OutputThread.cxx | 2 | ||||
-rw-r--r-- | src/filter/AutoConvertFilterPlugin.cxx (renamed from src/filter/autoconvert_filter_plugin.c) | 78 | ||||
-rw-r--r-- | src/filter/AutoConvertFilterPlugin.hxx (renamed from src/filter/autoconvert_filter_plugin.h) | 6 | ||||
-rw-r--r-- | src/filter/ConvertFilterPlugin.cxx (renamed from src/filter/convert_filter_plugin.c) | 42 | ||||
-rw-r--r-- | src/filter/ConvertFilterPlugin.hxx (renamed from src/filter/convert_filter_plugin.h) | 8 |
7 files changed, 75 insertions, 71 deletions
diff --git a/Makefile.am b/Makefile.am index f95cbd0c3..326251bc3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,9 +59,7 @@ mpd_headers = \ src/filter_internal.h \ src/filter_plugin.h \ src/filter_registry.h \ - src/filter/autoconvert_filter_plugin.h \ src/filter/chain_filter_plugin.h \ - src/filter/convert_filter_plugin.h \ src/filter/volume_filter_plugin.h \ src/command.h \ src/conf.h \ @@ -972,8 +970,10 @@ endif libfilter_plugins_a_SOURCES = \ src/filter/null_filter_plugin.c \ src/filter/chain_filter_plugin.c \ - src/filter/autoconvert_filter_plugin.c \ - src/filter/convert_filter_plugin.c \ + src/filter/AutoConvertFilterPlugin.cxx \ + src/filter/AutoConvertFilterPlugin.hxx \ + src/filter/ConvertFilterPlugin.cxx \ + src/filter/ConvertFilterPlugin.hxx \ src/filter/route_filter_plugin.c \ src/filter/normalize_filter_plugin.c \ src/filter/ReplayGainFilterPlugin.cxx \ diff --git a/src/OutputInit.cxx b/src/OutputInit.cxx index 0e9f851b2..037f9ea44 100644 --- a/src/OutputInit.cxx +++ b/src/OutputInit.cxx @@ -34,9 +34,9 @@ extern "C" { #include "filter_plugin.h" #include "filter_registry.h" #include "filter/chain_filter_plugin.h" -#include "filter/autoconvert_filter_plugin.h" } +#include "filter/AutoConvertFilterPlugin.hxx" #include "filter/ReplayGainFilterPlugin.hxx" #include <glib.h> diff --git a/src/OutputThread.cxx b/src/OutputThread.cxx index 685475be3..fbbab98ea 100644 --- a/src/OutputThread.cxx +++ b/src/OutputThread.cxx @@ -25,10 +25,10 @@ extern "C" { #include "output_internal.h" #include "pcm_mix.h" #include "filter_plugin.h" -#include "filter/convert_filter_plugin.h" } #include "notify.hxx" +#include "filter/ConvertFilterPlugin.hxx" #include "filter/ReplayGainFilterPlugin.hxx" #include "PlayerControl.hxx" #include "MusicPipe.hxx" diff --git a/src/filter/autoconvert_filter_plugin.c b/src/filter/AutoConvertFilterPlugin.cxx index daa660521..3a8c087ba 100644 --- a/src/filter/autoconvert_filter_plugin.c +++ b/src/filter/AutoConvertFilterPlugin.cxx @@ -18,18 +18,16 @@ */ #include "config.h" -#include "filter/autoconvert_filter_plugin.h" -#include "filter/convert_filter_plugin.h" +#include "AutoConvertFilterPlugin.hxx" +#include "ConvertFilterPlugin.hxx" #include "filter_plugin.h" #include "filter_internal.h" #include "filter_registry.h" #include "audio_format.h" -#include <glib.h> - #include <assert.h> -struct autoconvert_filter { +struct AutoConvertFilter { struct filter base; /** @@ -45,20 +43,27 @@ struct autoconvert_filter { struct filter *filter; /** - * A convert_filter, just in case conversion is needed. NULL + * A convert_filter, just in case conversion is needed. nullptr * if unused. */ struct filter *convert; + + AutoConvertFilter(const filter_plugin &plugin, struct filter *_filter) + :filter(_filter) { + filter_init(&base, &plugin); + } + + ~AutoConvertFilter() { + filter_free(filter); + } }; static void autoconvert_filter_finish(struct filter *_filter) { - struct autoconvert_filter *filter = - (struct autoconvert_filter *)_filter; + AutoConvertFilter *filter = (AutoConvertFilter *)_filter; - filter_free(filter->filter); - g_free(filter); + delete filter; } static const struct audio_format * @@ -66,8 +71,7 @@ autoconvert_filter_open(struct filter *_filter, struct audio_format *in_audio_format, GError **error_r) { - struct autoconvert_filter *filter = - (struct autoconvert_filter *)_filter; + AutoConvertFilter *filter = (AutoConvertFilter *)_filter; const struct audio_format *out_audio_format; assert(audio_format_valid(in_audio_format)); @@ -78,8 +82,8 @@ autoconvert_filter_open(struct filter *_filter, out_audio_format = filter_open(filter->filter, &filter->in_audio_format, error_r); - if (out_audio_format == NULL) - return NULL; + if (out_audio_format == nullptr) + return nullptr; /* need to convert? */ @@ -88,19 +92,19 @@ autoconvert_filter_open(struct filter *_filter, struct audio_format audio_format2 = *in_audio_format; const struct audio_format *audio_format3; - filter->convert = filter_new(&convert_filter_plugin, NULL, + filter->convert = filter_new(&convert_filter_plugin, nullptr, error_r); - if (filter->convert == NULL) { + if (filter->convert == nullptr) { filter_close(filter->filter); - return NULL; + return nullptr; } audio_format3 = filter_open(filter->convert, &audio_format2, error_r); - if (audio_format3 == NULL) { + if (audio_format3 == nullptr) { filter_free(filter->convert); filter_close(filter->filter); - return NULL; + return nullptr; } assert(audio_format_equals(&audio_format2, in_audio_format)); @@ -108,7 +112,7 @@ autoconvert_filter_open(struct filter *_filter, convert_filter_set(filter->convert, &filter->in_audio_format); } else /* no */ - filter->convert = NULL; + filter->convert = nullptr; return out_audio_format; } @@ -116,10 +120,10 @@ autoconvert_filter_open(struct filter *_filter, static void autoconvert_filter_close(struct filter *_filter) { - struct autoconvert_filter *filter = - (struct autoconvert_filter *)_filter; + AutoConvertFilter *filter = + (AutoConvertFilter *)_filter; - if (filter->convert != NULL) { + if (filter->convert != nullptr) { filter_close(filter->convert); filter_free(filter->convert); } @@ -132,14 +136,13 @@ autoconvert_filter_filter(struct filter *_filter, const void *src, size_t src_size, size_t *dest_size_r, GError **error_r) { - struct autoconvert_filter *filter = - (struct autoconvert_filter *)_filter; + AutoConvertFilter *filter = (AutoConvertFilter *)_filter; - if (filter->convert != NULL) { + if (filter->convert != nullptr) { src = filter_filter(filter->convert, src, src_size, &src_size, error_r); - if (src == NULL) - return NULL; + if (src == nullptr) + return nullptr; } return filter_filter(filter->filter, src, src_size, dest_size_r, @@ -147,21 +150,20 @@ autoconvert_filter_filter(struct filter *_filter, const void *src, } static const struct filter_plugin autoconvert_filter_plugin = { - .name = "convert", - .finish = autoconvert_filter_finish, - .open = autoconvert_filter_open, - .close = autoconvert_filter_close, - .filter = autoconvert_filter_filter, + "convert", + nullptr, + autoconvert_filter_finish, + autoconvert_filter_open, + autoconvert_filter_close, + autoconvert_filter_filter, }; struct filter * autoconvert_filter_new(struct filter *_filter) { - struct autoconvert_filter *filter = - g_new(struct autoconvert_filter, 1); - - filter_init(&filter->base, &autoconvert_filter_plugin); - filter->filter = _filter; + AutoConvertFilter *filter = + new AutoConvertFilter(autoconvert_filter_plugin, + _filter); return &filter->base; } diff --git a/src/filter/autoconvert_filter_plugin.h b/src/filter/AutoConvertFilterPlugin.hxx index def08ab7e..062efcbd0 100644 --- a/src/filter/autoconvert_filter_plugin.h +++ b/src/filter/AutoConvertFilterPlugin.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 @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef AUTOCONVERT_FILTER_PLUGIN_H -#define AUTOCONVERT_FILTER_PLUGIN_H +#ifndef MPD_AUTOCONVERT_FILTER_PLUGIN_HXX +#define MPD_AUTOCONVERT_FILTER_PLUGIN_HXX struct filter; diff --git a/src/filter/convert_filter_plugin.c b/src/filter/ConvertFilterPlugin.cxx index c55b69af2..04f34842d 100644 --- a/src/filter/convert_filter_plugin.c +++ b/src/filter/ConvertFilterPlugin.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,7 +18,7 @@ */ #include "config.h" -#include "filter/convert_filter_plugin.h" +#include "ConvertFilterPlugin.hxx" #include "filter_plugin.h" #include "filter_internal.h" #include "filter_registry.h" @@ -30,7 +30,7 @@ #include <assert.h> #include <string.h> -struct convert_filter { +struct ConvertFilter { struct filter base; /** @@ -52,29 +52,31 @@ struct convert_filter { struct audio_format out_audio_format; struct pcm_convert_state state; + + ConvertFilter() { + filter_init(&base, &convert_filter_plugin); + } }; static struct filter * -convert_filter_init(G_GNUC_UNUSED const struct config_param *param, - G_GNUC_UNUSED GError **error_r) +convert_filter_init(gcc_unused const struct config_param *param, + gcc_unused GError **error_r) { - struct convert_filter *filter = g_new(struct convert_filter, 1); - - filter_init(&filter->base, &convert_filter_plugin); + ConvertFilter *filter = new ConvertFilter(); return &filter->base; } static void convert_filter_finish(struct filter *filter) { - g_free(filter); + delete filter; } static const struct audio_format * convert_filter_open(struct filter *_filter, struct audio_format *audio_format, - G_GNUC_UNUSED GError **error_r) + gcc_unused GError **error_r) { - struct convert_filter *filter = (struct convert_filter *)_filter; + ConvertFilter *filter = (ConvertFilter *)_filter; assert(audio_format_valid(audio_format)); @@ -87,7 +89,7 @@ convert_filter_open(struct filter *_filter, struct audio_format *audio_format, static void convert_filter_close(struct filter *_filter) { - struct convert_filter *filter = (struct convert_filter *)_filter; + ConvertFilter *filter = (ConvertFilter *)_filter; pcm_convert_deinit(&filter->state); @@ -101,7 +103,7 @@ static const void * convert_filter_filter(struct filter *_filter, const void *src, size_t src_size, size_t *dest_size_r, GError **error_r) { - struct convert_filter *filter = (struct convert_filter *)_filter; + ConvertFilter *filter = (ConvertFilter *)_filter; const void *dest; if (audio_format_equals(&filter->in_audio_format, @@ -122,19 +124,19 @@ convert_filter_filter(struct filter *_filter, const void *src, size_t src_size, } const struct filter_plugin convert_filter_plugin = { - .name = "convert", - .init = convert_filter_init, - .finish = convert_filter_finish, - .open = convert_filter_open, - .close = convert_filter_close, - .filter = convert_filter_filter, + "convert", + convert_filter_init, + convert_filter_finish, + convert_filter_open, + convert_filter_close, + convert_filter_filter, }; void convert_filter_set(struct filter *_filter, const struct audio_format *out_audio_format) { - struct convert_filter *filter = (struct convert_filter *)_filter; + ConvertFilter *filter = (ConvertFilter *)_filter; assert(filter != NULL); assert(audio_format_valid(&filter->in_audio_format)); diff --git a/src/filter/convert_filter_plugin.h b/src/filter/ConvertFilterPlugin.hxx index 156adf8e3..15f0fa92c 100644 --- a/src/filter/convert_filter_plugin.h +++ b/src/filter/ConvertFilterPlugin.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 @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef CONVERT_FILTER_PLUGIN_H -#define CONVERT_FILTER_PLUGIN_H +#ifndef MPD_CONVERT_FILTER_PLUGIN_HXX +#define MPD_CONVERT_FILTER_PLUGIN_HXX struct filter; struct audio_format; @@ -31,6 +31,6 @@ struct audio_format; */ void convert_filter_set(struct filter *filter, - const struct audio_format *out_audio_format); + const audio_format *out_audio_format); #endif |