aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--src/MixerAll.cxx11
-rw-r--r--src/MixerControl.cxx22
-rw-r--r--src/MixerControl.hxx16
-rw-r--r--src/MixerInternal.cxx33
-rw-r--r--src/MixerInternal.hxx17
-rw-r--r--src/MixerPlugin.hxx16
-rw-r--r--src/OutputCommand.cxx3
-rw-r--r--src/OutputInit.cxx4
-rw-r--r--src/filter/ReplayGainFilterPlugin.cxx6
-rw-r--r--src/filter/ReplayGainFilterPlugin.hxx4
-rw-r--r--src/mixer/AlsaMixerPlugin.cxx18
-rw-r--r--src/mixer/OssMixerPlugin.cxx18
-rw-r--r--src/mixer/PulseMixerPlugin.cxx14
-rw-r--r--src/mixer/RoarMixerPlugin.cxx20
-rw-r--r--src/mixer/SoftwareMixerPlugin.cxx22
-rw-r--r--src/mixer/SoftwareMixerPlugin.hxx4
-rw-r--r--src/mixer/WinmmMixerPlugin.cxx14
-rw-r--r--src/output_internal.h4
-rw-r--r--test/read_mixer.cxx3
-rw-r--r--test/run_filter.cxx2
21 files changed, 110 insertions, 145 deletions
diff --git a/Makefile.am b/Makefile.am
index 8b1a3d8cb..e327f60b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -795,7 +795,7 @@ MIXER_API_SRC = \
src/MixerControl.cxx src/MixerControl.hxx \
src/MixerType.cxx src/MixerType.hxx \
src/MixerAll.cxx src/MixerAll.hxx \
- src/MixerInternal.cxx src/MixerInternal.hxx
+ src/MixerInternal.hxx
libmixer_plugins_a_SOURCES = \
src/mixer/SoftwareMixerPlugin.cxx \
@@ -1325,7 +1325,6 @@ test_run_output_SOURCES = test/run_output.cxx \
src/resolver.c \
src/OutputInit.cxx src/OutputFinish.cxx src/OutputList.cxx \
src/OutputPlugin.cxx \
- src/MixerInternal.cxx \
src/MixerControl.cxx \
src/MixerType.cxx \
src/FilterPlugin.cxx \
@@ -1345,7 +1344,6 @@ test_read_mixer_LDADD = \
$(GLIB_LIBS)
test_read_mixer_SOURCES = test/read_mixer.cxx \
src/MixerControl.cxx \
- src/MixerInternal.cxx \
src/FilterPlugin.cxx \
src/filter/VolumeFilterPlugin.cxx \
src/fd_util.c
diff --git a/src/MixerAll.cxx b/src/MixerAll.cxx
index 36c83abf8..3069f60d7 100644
--- a/src/MixerAll.cxx
+++ b/src/MixerAll.cxx
@@ -40,7 +40,6 @@ static int
output_mixer_get_volume(unsigned i)
{
struct audio_output *output;
- struct mixer *mixer;
int volume;
GError *error = NULL;
@@ -50,7 +49,7 @@ output_mixer_get_volume(unsigned i)
if (!output->enabled)
return -1;
- mixer = output->mixer;
+ Mixer *mixer = output->mixer;
if (mixer == NULL)
return -1;
@@ -88,7 +87,6 @@ static bool
output_mixer_set_volume(unsigned i, unsigned volume)
{
struct audio_output *output;
- struct mixer *mixer;
bool success;
GError *error = NULL;
@@ -99,7 +97,7 @@ output_mixer_set_volume(unsigned i, unsigned volume)
if (!output->enabled)
return false;
- mixer = output->mixer;
+ Mixer *mixer = output->mixer;
if (mixer == NULL)
return false;
@@ -132,7 +130,6 @@ static int
output_mixer_get_software_volume(unsigned i)
{
struct audio_output *output;
- struct mixer *mixer;
assert(i < audio_output_count());
@@ -140,8 +137,8 @@ output_mixer_get_software_volume(unsigned i)
if (!output->enabled)
return -1;
- mixer = output->mixer;
- if (mixer == NULL || mixer->plugin != &software_mixer_plugin)
+ Mixer *mixer = output->mixer;
+ if (mixer == NULL || !mixer->IsPlugin(software_mixer_plugin))
return -1;
return mixer_get_volume(mixer, NULL);
diff --git a/src/MixerControl.cxx b/src/MixerControl.cxx
index 4ca1c76ec..7bba4d46b 100644
--- a/src/MixerControl.cxx
+++ b/src/MixerControl.cxx
@@ -27,24 +27,24 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mixer"
-struct mixer *
+Mixer *
mixer_new(const struct mixer_plugin *plugin, void *ao,
const struct config_param *param,
GError **error_r)
{
- struct mixer *mixer;
+ Mixer *mixer;
assert(plugin != NULL);
mixer = plugin->init(ao, param, error_r);
- assert(mixer == NULL || mixer->plugin == plugin);
+ assert(mixer == NULL || mixer->IsPlugin(*plugin));
return mixer;
}
void
-mixer_free(struct mixer *mixer)
+mixer_free(Mixer *mixer)
{
assert(mixer != NULL);
assert(mixer->plugin != NULL);
@@ -60,7 +60,7 @@ mixer_free(struct mixer *mixer)
}
bool
-mixer_open(struct mixer *mixer, GError **error_r)
+mixer_open(Mixer *mixer, GError **error_r)
{
bool success;
@@ -84,7 +84,7 @@ mixer_open(struct mixer *mixer, GError **error_r)
}
static void
-mixer_close_internal(struct mixer *mixer)
+mixer_close_internal(Mixer *mixer)
{
assert(mixer != NULL);
assert(mixer->plugin != NULL);
@@ -97,7 +97,7 @@ mixer_close_internal(struct mixer *mixer)
}
void
-mixer_close(struct mixer *mixer)
+mixer_close(Mixer *mixer)
{
assert(mixer != NULL);
assert(mixer->plugin != NULL);
@@ -111,7 +111,7 @@ mixer_close(struct mixer *mixer)
}
void
-mixer_auto_close(struct mixer *mixer)
+mixer_auto_close(Mixer *mixer)
{
if (!mixer->plugin->global)
mixer_close(mixer);
@@ -122,7 +122,7 @@ mixer_auto_close(struct mixer *mixer)
* calling this function.
*/
static void
-mixer_failed(struct mixer *mixer)
+mixer_failed(Mixer *mixer)
{
assert(mixer->open);
@@ -132,7 +132,7 @@ mixer_failed(struct mixer *mixer)
}
int
-mixer_get_volume(struct mixer *mixer, GError **error_r)
+mixer_get_volume(Mixer *mixer, GError **error_r)
{
int volume;
@@ -161,7 +161,7 @@ mixer_get_volume(struct mixer *mixer, GError **error_r)
}
bool
-mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
+mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
{
bool success;
diff --git a/src/MixerControl.hxx b/src/MixerControl.hxx
index ee1e959da..1e01e111a 100644
--- a/src/MixerControl.hxx
+++ b/src/MixerControl.hxx
@@ -27,7 +27,7 @@
#include "gerror.h"
-struct mixer;
+class Mixer;
struct mixer_plugin;
struct config_param;
@@ -35,32 +35,32 @@ struct config_param;
extern "C" {
#endif
-struct mixer *
+Mixer *
mixer_new(const struct mixer_plugin *plugin, void *ao,
const struct config_param *param,
GError **error_r);
void
-mixer_free(struct mixer *mixer);
+mixer_free(Mixer *mixer);
bool
-mixer_open(struct mixer *mixer, GError **error_r);
+mixer_open(Mixer *mixer, GError **error_r);
void
-mixer_close(struct mixer *mixer);
+mixer_close(Mixer *mixer);
/**
* Close the mixer unless the plugin's "global" flag is set. This is
* called when the #audio_output is closed.
*/
void
-mixer_auto_close(struct mixer *mixer);
+mixer_auto_close(Mixer *mixer);
int
-mixer_get_volume(struct mixer *mixer, GError **error_r);
+mixer_get_volume(Mixer *mixer, GError **error_r);
bool
-mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r);
+mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r);
#ifdef __cplusplus
}
diff --git a/src/MixerInternal.cxx b/src/MixerInternal.cxx
deleted file mode 100644
index b8729fc7e..000000000
--- a/src/MixerInternal.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-#include "MixerInternal.hxx"
-
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "mixer"
-
-void
-mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin)
-{
- mixer->plugin = plugin;
- mixer->mutex = g_mutex_new();
- mixer->open = false;
- mixer->failed = false;
-}
diff --git a/src/MixerInternal.hxx b/src/MixerInternal.hxx
index 9c39e3e35..f922a22bd 100644
--- a/src/MixerInternal.hxx
+++ b/src/MixerInternal.hxx
@@ -25,7 +25,8 @@
#include <glib.h>
-struct mixer {
+class Mixer {
+public:
const struct mixer_plugin *plugin;
/**
@@ -44,9 +45,17 @@ struct mixer {
* automatically?
*/
bool failed;
-};
-void
-mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin);
+public:
+ Mixer(const mixer_plugin &_plugin)
+ :plugin(&_plugin),
+ mutex(g_mutex_new()),
+ open(false),
+ failed(false) {}
+
+ bool IsPlugin(const mixer_plugin &other) const {
+ return plugin == &other;
+ }
+};
#endif
diff --git a/src/MixerPlugin.hxx b/src/MixerPlugin.hxx
index 1fbdfbbc2..cc57a76a9 100644
--- a/src/MixerPlugin.hxx
+++ b/src/MixerPlugin.hxx
@@ -32,7 +32,7 @@
#include <stdbool.h>
struct config_param;
-struct mixer;
+class Mixer;
struct mixer_plugin {
/**
@@ -45,13 +45,13 @@ struct mixer_plugin {
* NULL to ignore errors
* @return a mixer object, or NULL on error
*/
- struct mixer *(*init)(void *ao, const struct config_param *param,
- GError **error_r);
+ Mixer *(*init)(void *ao, const struct config_param *param,
+ GError **error_r);
/**
* Finish and free mixer data
*/
- void (*finish)(struct mixer *data);
+ void (*finish)(Mixer *data);
/**
* Open mixer device
@@ -60,12 +60,12 @@ struct mixer_plugin {
* NULL to ignore errors
* @return true on success, false on error
*/
- bool (*open)(struct mixer *data, GError **error_r);
+ bool (*open)(Mixer *data, GError **error_r);
/**
* Close mixer device
*/
- void (*close)(struct mixer *data);
+ void (*close)(Mixer *data);
/**
* Reads the current volume.
@@ -75,7 +75,7 @@ struct mixer_plugin {
* @return the current volume (0..100 including) or -1 if
* unavailable or on error (error_r set, mixer will be closed)
*/
- int (*get_volume)(struct mixer *mixer, GError **error_r);
+ int (*get_volume)(Mixer *mixer, GError **error_r);
/**
* Sets the volume.
@@ -85,7 +85,7 @@ struct mixer_plugin {
* @param volume the new volume (0..100 including)
* @return true on success, false on error
*/
- bool (*set_volume)(struct mixer *mixer, unsigned volume,
+ bool (*set_volume)(Mixer *mixer, unsigned volume,
GError **error_r);
/**
diff --git a/src/OutputCommand.cxx b/src/OutputCommand.cxx
index beb44f0ef..3921a9634 100644
--- a/src/OutputCommand.cxx
+++ b/src/OutputCommand.cxx
@@ -64,7 +64,6 @@ bool
audio_output_disable_index(unsigned idx)
{
struct audio_output *ao;
- struct mixer *mixer;
if (idx >= audio_output_count())
return false;
@@ -76,7 +75,7 @@ audio_output_disable_index(unsigned idx)
ao->enabled = false;
idle_add(IDLE_OUTPUT);
- mixer = ao->mixer;
+ Mixer *mixer = ao->mixer;
if (mixer != NULL) {
mixer_close(mixer);
idle_add(IDLE_MIXER);
diff --git a/src/OutputInit.cxx b/src/OutputInit.cxx
index de6869256..c3a71c129 100644
--- a/src/OutputInit.cxx
+++ b/src/OutputInit.cxx
@@ -96,14 +96,14 @@ audio_output_mixer_type(const struct config_param *param)
"hardware"));
}
-static struct mixer *
+static Mixer *
audio_output_load_mixer(struct audio_output *ao,
const struct config_param *param,
const struct mixer_plugin *plugin,
Filter &filter_chain,
GError **error_r)
{
- struct mixer *mixer;
+ Mixer *mixer;
switch (audio_output_mixer_type(param)) {
case MIXER_TYPE_NONE:
diff --git a/src/filter/ReplayGainFilterPlugin.cxx b/src/filter/ReplayGainFilterPlugin.cxx
index fed474bd5..f590d57f5 100644
--- a/src/filter/ReplayGainFilterPlugin.cxx
+++ b/src/filter/ReplayGainFilterPlugin.cxx
@@ -43,7 +43,7 @@ class ReplayGainFilter final : public Filter {
* If set, then this hardware mixer is used for applying
* replay gain, instead of the software volume library.
*/
- struct mixer *mixer;
+ Mixer *mixer;
/**
* The base volume level for scale=1.0, between 1 and 100
@@ -80,7 +80,7 @@ public:
replay_gain_info_init(&info);
}
- void SetMixer(struct mixer *_mixer, unsigned _base) {
+ void SetMixer(Mixer *_mixer, unsigned _base) {
assert(_mixer == NULL || (_base > 0 && _base <= 100));
mixer = _mixer;
@@ -217,7 +217,7 @@ const struct filter_plugin replay_gain_filter_plugin = {
};
void
-replay_gain_filter_set_mixer(Filter *_filter, struct mixer *mixer,
+replay_gain_filter_set_mixer(Filter *_filter, Mixer *mixer,
unsigned base)
{
ReplayGainFilter *filter = (ReplayGainFilter *)_filter;
diff --git a/src/filter/ReplayGainFilterPlugin.hxx b/src/filter/ReplayGainFilterPlugin.hxx
index dd8ceb953..06b778f8f 100644
--- a/src/filter/ReplayGainFilterPlugin.hxx
+++ b/src/filter/ReplayGainFilterPlugin.hxx
@@ -23,7 +23,7 @@
#include "replay_gain_info.h"
class Filter;
-struct mixer;
+class Mixer;
/**
* Enables or disables the hardware mixer for applying replay gain.
@@ -34,7 +34,7 @@ struct mixer;
* (including).
*/
void
-replay_gain_filter_set_mixer(Filter *_filter, struct mixer *mixer,
+replay_gain_filter_set_mixer(Filter *_filter, Mixer *mixer,
unsigned base);
/**
diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx
index f4ace573c..68ad859ff 100644
--- a/src/mixer/AlsaMixerPlugin.cxx
+++ b/src/mixer/AlsaMixerPlugin.cxx
@@ -45,7 +45,7 @@ private:
virtual void DispatchSockets() override;
};
-class AlsaMixer final : public mixer {
+class AlsaMixer final : public Mixer {
const char *device;
const char *control;
unsigned int index;
@@ -59,9 +59,7 @@ class AlsaMixer final : public mixer {
AlsaMixerMonitor *monitor;
public:
- AlsaMixer() {
- mixer_init(this, &alsa_mixer_plugin);
- }
+ AlsaMixer():Mixer(alsa_mixer_plugin) {}
void Configure(const config_param *param);
bool Setup(GError **error_r);
@@ -150,7 +148,7 @@ AlsaMixer::Configure(const config_param *param)
VOLUME_MIXER_ALSA_INDEX_DEFAULT);
}
-static struct mixer *
+static Mixer *
alsa_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
{
@@ -161,7 +159,7 @@ alsa_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
}
static void
-alsa_mixer_finish(struct mixer *data)
+alsa_mixer_finish(Mixer *data)
{
AlsaMixer *am = (AlsaMixer *)data;
@@ -254,7 +252,7 @@ AlsaMixer::Open(GError **error_r)
}
static bool
-alsa_mixer_open(struct mixer *data, GError **error_r)
+alsa_mixer_open(Mixer *data, GError **error_r)
{
AlsaMixer *am = (AlsaMixer *)data;
@@ -273,7 +271,7 @@ AlsaMixer::Close()
}
static void
-alsa_mixer_close(struct mixer *data)
+alsa_mixer_close(Mixer *data)
{
AlsaMixer *am = (AlsaMixer *)data;
am->Close();
@@ -319,7 +317,7 @@ AlsaMixer::GetVolume(GError **error_r)
}
static int
-alsa_mixer_get_volume(struct mixer *mixer, GError **error_r)
+alsa_mixer_get_volume(Mixer *mixer, GError **error_r)
{
AlsaMixer *am = (AlsaMixer *)mixer;
return am->GetVolume(error_r);
@@ -355,7 +353,7 @@ AlsaMixer::SetVolume(unsigned volume, GError **error_r)
}
static bool
-alsa_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
+alsa_mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
{
AlsaMixer *am = (AlsaMixer *)mixer;
return am->SetVolume(volume, error_r);
diff --git a/src/mixer/OssMixerPlugin.cxx b/src/mixer/OssMixerPlugin.cxx
index 83bc31f9f..24471c035 100644
--- a/src/mixer/OssMixerPlugin.cxx
+++ b/src/mixer/OssMixerPlugin.cxx
@@ -40,7 +40,7 @@
#define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer"
-class OssMixer : public mixer {
+class OssMixer : public Mixer {
const char *device;
const char *control;
@@ -48,9 +48,7 @@ class OssMixer : public mixer {
int volume_control;
public:
- OssMixer() {
- mixer_init(this, &oss_mixer_plugin);
- }
+ OssMixer():Mixer(oss_mixer_plugin) {}
bool Configure(const config_param *param, GError **error_r);
bool Open(GError **error_r);
@@ -104,7 +102,7 @@ OssMixer::Configure(const config_param *param, GError **error_r)
return true;
}
-static struct mixer *
+static Mixer *
oss_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
GError **error_r)
{
@@ -119,7 +117,7 @@ oss_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
}
static void
-oss_mixer_finish(struct mixer *data)
+oss_mixer_finish(Mixer *data)
{
OssMixer *om = (OssMixer *) data;
@@ -135,7 +133,7 @@ OssMixer::Close()
}
static void
-oss_mixer_close(struct mixer *data)
+oss_mixer_close(Mixer *data)
{
OssMixer *om = (OssMixer *) data;
om->Close();
@@ -176,7 +174,7 @@ OssMixer::Open(GError **error_r)
}
static bool
-oss_mixer_open(struct mixer *data, GError **error_r)
+oss_mixer_open(Mixer *data, GError **error_r)
{
OssMixer *om = (OssMixer *) data;
@@ -211,7 +209,7 @@ OssMixer::GetVolume(GError **error_r)
}
static int
-oss_mixer_get_volume(struct mixer *mixer, GError **error_r)
+oss_mixer_get_volume(Mixer *mixer, GError **error_r)
{
OssMixer *om = (OssMixer *)mixer;
return om->GetVolume(error_r);
@@ -240,7 +238,7 @@ OssMixer::SetVolume(unsigned volume, GError **error_r)
}
static bool
-oss_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
+oss_mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
{
OssMixer *om = (OssMixer *)mixer;
return om->SetVolume(volume, error_r);
diff --git a/src/mixer/PulseMixerPlugin.cxx b/src/mixer/PulseMixerPlugin.cxx
index 99e381952..389f077f3 100644
--- a/src/mixer/PulseMixerPlugin.cxx
+++ b/src/mixer/PulseMixerPlugin.cxx
@@ -39,16 +39,16 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "pulse_mixer"
-struct PulseMixer : mixer {
+struct PulseMixer final : public Mixer {
PulseOutput *output;
bool online;
struct pa_cvolume volume;
PulseMixer(PulseOutput *_output)
- :output(_output), online(false)
+ :Mixer(pulse_mixer_plugin),
+ output(_output), online(false)
{
- mixer_init(this, &pulse_mixer_plugin);
}
};
@@ -152,7 +152,7 @@ pulse_mixer_on_change(PulseMixer *pm,
pulse_mixer_update(pm, context, stream);
}
-static struct mixer *
+static Mixer *
pulse_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
GError **error_r)
{
@@ -172,7 +172,7 @@ pulse_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
}
static void
-pulse_mixer_finish(struct mixer *data)
+pulse_mixer_finish(Mixer *data)
{
PulseMixer *pm = (PulseMixer *) data;
@@ -182,7 +182,7 @@ pulse_mixer_finish(struct mixer *data)
}
static int
-pulse_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
+pulse_mixer_get_volume(Mixer *mixer, G_GNUC_UNUSED GError **error_r)
{
PulseMixer *pm = (PulseMixer *) mixer;
int ret;
@@ -199,7 +199,7 @@ pulse_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
}
static bool
-pulse_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
+pulse_mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
{
PulseMixer *pm = (PulseMixer *) mixer;
struct pa_cvolume cvolume;
diff --git a/src/mixer/RoarMixerPlugin.cxx b/src/mixer/RoarMixerPlugin.cxx
index a027f8570..0533711c1 100644
--- a/src/mixer/RoarMixerPlugin.cxx
+++ b/src/mixer/RoarMixerPlugin.cxx
@@ -24,26 +24,24 @@
#include "output_api.h"
#include "output/RoarOutputPlugin.hxx"
-struct RoarMixer {
+struct RoarMixer final : public Mixer {
/** the base mixer class */
- struct mixer base;
RoarOutput *self;
- RoarMixer(RoarOutput *_output):self(_output) {
- mixer_init(&base, &roar_mixer_plugin);
- }
+ RoarMixer(RoarOutput *_output)
+ :Mixer(roar_mixer_plugin),
+ self(_output) {}
};
-static struct mixer *
+static Mixer *
roar_mixer_init(void *ao, gcc_unused const struct config_param *param,
gcc_unused GError **error_r)
{
- RoarMixer *self = new RoarMixer((RoarOutput *)ao);
- return &self->base;
+ return new RoarMixer((RoarOutput *)ao);
}
static void
-roar_mixer_finish(struct mixer *data)
+roar_mixer_finish(Mixer *data)
{
RoarMixer *self = (RoarMixer *) data;
@@ -51,14 +49,14 @@ roar_mixer_finish(struct mixer *data)
}
static int
-roar_mixer_get_volume(struct mixer *mixer, gcc_unused GError **error_r)
+roar_mixer_get_volume(Mixer *mixer, gcc_unused GError **error_r)
{
RoarMixer *self = (RoarMixer *)mixer;
return roar_output_get_volume(self->self);
}
static bool
-roar_mixer_set_volume(struct mixer *mixer, unsigned volume,
+roar_mixer_set_volume(Mixer *mixer, unsigned volume,
gcc_unused GError **error_r)
{
RoarMixer *self = (RoarMixer *)mixer;
diff --git a/src/mixer/SoftwareMixerPlugin.cxx b/src/mixer/SoftwareMixerPlugin.cxx
index 2782495f5..20cbf45f0 100644
--- a/src/mixer/SoftwareMixerPlugin.cxx
+++ b/src/mixer/SoftwareMixerPlugin.cxx
@@ -29,18 +29,17 @@
#include <assert.h>
#include <math.h>
-struct SoftwareMixer final : public mixer {
+struct SoftwareMixer final : public Mixer {
Filter *filter;
unsigned volume;
SoftwareMixer()
- :filter(filter_new(&volume_filter_plugin, nullptr, nullptr)),
- volume(100)
+ :Mixer(software_mixer_plugin),
+ filter(filter_new(&volume_filter_plugin, nullptr, nullptr)),
+ volume(100)
{
assert(filter != nullptr);
-
- mixer_init(this, &software_mixer_plugin);
}
~SoftwareMixer() {
@@ -48,7 +47,7 @@ struct SoftwareMixer final : public mixer {
}
};
-static struct mixer *
+static Mixer *
software_mixer_init(G_GNUC_UNUSED void *ao,
G_GNUC_UNUSED const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
@@ -57,7 +56,7 @@ software_mixer_init(G_GNUC_UNUSED void *ao,
}
static void
-software_mixer_finish(struct mixer *data)
+software_mixer_finish(Mixer *data)
{
SoftwareMixer *sm = (SoftwareMixer *)data;
@@ -65,7 +64,7 @@ software_mixer_finish(struct mixer *data)
}
static int
-software_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
+software_mixer_get_volume(Mixer *mixer, G_GNUC_UNUSED GError **error_r)
{
SoftwareMixer *sm = (SoftwareMixer *)mixer;
@@ -73,7 +72,7 @@ software_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
}
static bool
-software_mixer_set_volume(struct mixer *mixer, unsigned volume,
+software_mixer_set_volume(Mixer *mixer, unsigned volume,
G_GNUC_UNUSED GError **error_r)
{
SoftwareMixer *sm = (SoftwareMixer *)mixer;
@@ -103,11 +102,10 @@ const struct mixer_plugin software_mixer_plugin = {
};
Filter *
-software_mixer_get_filter(struct mixer *mixer)
+software_mixer_get_filter(Mixer *mixer)
{
SoftwareMixer *sm = (SoftwareMixer *)mixer;
-
- assert(sm->plugin == &software_mixer_plugin);
+ assert(sm->IsPlugin(software_mixer_plugin));
return sm->filter;
}
diff --git a/src/mixer/SoftwareMixerPlugin.hxx b/src/mixer/SoftwareMixerPlugin.hxx
index 33e9e6c6f..be59c08db 100644
--- a/src/mixer/SoftwareMixerPlugin.hxx
+++ b/src/mixer/SoftwareMixerPlugin.hxx
@@ -20,7 +20,7 @@
#ifndef MPD_SOFTWARE_MIXER_PLUGIN_HXX
#define MPD_SOFTWARE_MIXER_PLUGIN_HXX
-struct mixer;
+class Mixer;
class Filter;
/**
@@ -28,6 +28,6 @@ class Filter;
* of this mixer plugin should install this filter.
*/
Filter *
-software_mixer_get_filter(struct mixer *mixer);
+software_mixer_get_filter(Mixer *mixer);
#endif
diff --git a/src/mixer/WinmmMixerPlugin.cxx b/src/mixer/WinmmMixerPlugin.cxx
index bca14f51f..73013fd93 100644
--- a/src/mixer/WinmmMixerPlugin.cxx
+++ b/src/mixer/WinmmMixerPlugin.cxx
@@ -31,12 +31,12 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "winmm_mixer"
-struct WinmmMixer final : public mixer {
+struct WinmmMixer final : public Mixer {
WinmmOutput *output;
WinmmMixer(WinmmOutput *_output)
- :output(_output) {
- mixer_init(this, &winmm_mixer_plugin);
+ :Mixer(winmm_mixer_plugin),
+ output(_output) {
}
};
@@ -59,7 +59,7 @@ winmm_volume_encode(int volume)
return MAKELONG(value, value);
}
-static struct mixer *
+static Mixer *
winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
G_GNUC_UNUSED GError **error_r)
{
@@ -69,7 +69,7 @@ winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
}
static void
-winmm_mixer_finish(struct mixer *data)
+winmm_mixer_finish(Mixer *data)
{
WinmmMixer *wm = (WinmmMixer *)data;
@@ -77,7 +77,7 @@ winmm_mixer_finish(struct mixer *data)
}
static int
-winmm_mixer_get_volume(struct mixer *mixer, GError **error_r)
+winmm_mixer_get_volume(Mixer *mixer, GError **error_r)
{
WinmmMixer *wm = (WinmmMixer *) mixer;
DWORD volume;
@@ -94,7 +94,7 @@ winmm_mixer_get_volume(struct mixer *mixer, GError **error_r)
}
static bool
-winmm_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
+winmm_mixer_set_volume(Mixer *mixer, unsigned volume, GError **error_r)
{
WinmmMixer *wm = (WinmmMixer *) mixer;
DWORD value = winmm_volume_encode(volume);
diff --git a/src/output_internal.h b/src/output_internal.h
index 8d0177786..ed4188af0 100644
--- a/src/output_internal.h
+++ b/src/output_internal.h
@@ -76,7 +76,11 @@ struct audio_output {
* May be NULL if none is available, or if software volume is
* configured.
*/
+#ifdef __cplusplus
+ class Mixer *mixer;
+#else
struct mixer *mixer;
+#endif
/**
* Will this output receive tags from the decoder? The
diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx
index 9f9db1e0c..c96f0f630 100644
--- a/test/read_mixer.cxx
+++ b/test/read_mixer.cxx
@@ -111,7 +111,6 @@ pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED size_t length,
int main(int argc, G_GNUC_UNUSED char **argv)
{
GError *error = NULL;
- struct mixer *mixer;
bool success;
int volume;
@@ -124,7 +123,7 @@ int main(int argc, G_GNUC_UNUSED char **argv)
main_loop = new EventLoop(EventLoop::Default());
- mixer = mixer_new(&alsa_mixer_plugin, NULL, NULL, &error);
+ Mixer *mixer = mixer_new(&alsa_mixer_plugin, NULL, NULL, &error);
if (mixer == NULL) {
g_printerr("mixer_new() failed: %s\n", error->message);
g_error_free(error);
diff --git a/test/run_filter.cxx b/test/run_filter.cxx
index 0b8078c1a..8dde8fb65 100644
--- a/test/run_filter.cxx
+++ b/test/run_filter.cxx
@@ -36,7 +36,7 @@
#include <unistd.h>
bool
-mixer_set_volume(G_GNUC_UNUSED struct mixer *mixer,
+mixer_set_volume(gcc_unused Mixer *mixer,
G_GNUC_UNUSED unsigned volume, G_GNUC_UNUSED GError **error_r)
{
return true;