aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-04-16 21:25:27 +0200
committerMax Kellermann <max@duempel.org>2013-04-16 21:25:27 +0200
commit506c716cf231182fa2ce9b791963f07c6b27036d (patch)
tree116ba9940b229ccafaaf0f3520c2bd7f615cd900 /src/mixer
parent9f625b0a0da86b0a75de5b3805085301d6690cf1 (diff)
downloadmpd-506c716cf231182fa2ce9b791963f07c6b27036d.tar.gz
mpd-506c716cf231182fa2ce9b791963f07c6b27036d.tar.xz
mpd-506c716cf231182fa2ce9b791963f07c6b27036d.zip
mixer/Software: convert to a class
Diffstat (limited to 'src/mixer')
-rw-r--r--src/mixer/SoftwareMixerPlugin.cxx42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx
index ccadadb4d..2782495f5 100644
--- a/src/mixer/SoftwareMixerPlugin.cxx
+++ b/src/mixer/SoftwareMixerPlugin.cxx
@@ -22,19 +22,30 @@
#include "MixerInternal.hxx"
#include "FilterPlugin.hxx"
#include "FilterRegistry.hxx"
+#include "FilterInternal.hxx"
#include "filter/VolumeFilterPlugin.hxx"
#include "pcm/PcmVolume.hxx"
#include <assert.h>
#include <math.h>
-struct software_mixer {
- /** the base mixer class */
- struct mixer base;
-
+struct SoftwareMixer final : public mixer {
Filter *filter;
unsigned volume;
+
+ SoftwareMixer()
+ :filter(filter_new(&volume_filter_plugin, nullptr, nullptr)),
+ volume(100)
+ {
+ assert(filter != nullptr);
+
+ mixer_init(this, &software_mixer_plugin);
+ }
+
+ ~SoftwareMixer() {
+ delete filter;
+ }
};
static struct mixer *
@@ -42,30 +53,21 @@ software_mixer_init(G_GNUC_UNUSED void *ao,
G_GNUC_UNUSED const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
{
- struct software_mixer *sm = g_new(struct software_mixer, 1);
-
- mixer_init(&sm->base, &software_mixer_plugin);
-
- sm->filter = filter_new(&volume_filter_plugin, NULL, NULL);
- assert(sm->filter != NULL);
-
- sm->volume = 100;
-
- return &sm->base;
+ return new SoftwareMixer();
}
static void
software_mixer_finish(struct mixer *data)
{
- struct software_mixer *sm = (struct software_mixer *)data;
+ SoftwareMixer *sm = (SoftwareMixer *)data;
- g_free(sm);
+ delete sm;
}
static int
software_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
{
- struct software_mixer *sm = (struct software_mixer *)mixer;
+ SoftwareMixer *sm = (SoftwareMixer *)mixer;
return sm->volume;
}
@@ -74,7 +76,7 @@ static bool
software_mixer_set_volume(struct mixer *mixer, unsigned volume,
G_GNUC_UNUSED GError **error_r)
{
- struct software_mixer *sm = (struct software_mixer *)mixer;
+ SoftwareMixer *sm = (SoftwareMixer *)mixer;
assert(volume <= 100);
@@ -103,9 +105,9 @@ const struct mixer_plugin software_mixer_plugin = {
Filter *
software_mixer_get_filter(struct mixer *mixer)
{
- struct software_mixer *sm = (struct software_mixer *)mixer;
+ SoftwareMixer *sm = (SoftwareMixer *)mixer;
- assert(sm->base.plugin == &software_mixer_plugin);
+ assert(sm->plugin == &software_mixer_plugin);
return sm->filter;
}