MixerInternal: convert to class
This commit is contained in:
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user