diff options
author | Max Kellermann <max@duempel.org> | 2013-04-16 20:47:55 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-04-16 21:18:54 +0200 |
commit | 9f625b0a0da86b0a75de5b3805085301d6690cf1 (patch) | |
tree | cea9e06e4789bf0d4313d670669f791da9e4208e /src/mixer/PulseMixerPlugin.cxx | |
parent | bc1b4131cbee13fa892ff2d5be5b5e0bbf1ae43d (diff) | |
download | mpd-9f625b0a0da86b0a75de5b3805085301d6690cf1.tar.gz mpd-9f625b0a0da86b0a75de5b3805085301d6690cf1.tar.xz mpd-9f625b0a0da86b0a75de5b3805085301d6690cf1.zip |
mixer/Pulse: convert to a class
Diffstat (limited to 'src/mixer/PulseMixerPlugin.cxx')
-rw-r--r-- | src/mixer/PulseMixerPlugin.cxx | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/mixer/PulseMixerPlugin.cxx b/src/mixer/PulseMixerPlugin.cxx index 70d0247ac..99e381952 100644 --- a/src/mixer/PulseMixerPlugin.cxx +++ b/src/mixer/PulseMixerPlugin.cxx @@ -39,14 +39,17 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "pulse_mixer" -struct pulse_mixer { - struct mixer base; - +struct PulseMixer : mixer { PulseOutput *output; bool online; struct pa_cvolume volume; + PulseMixer(PulseOutput *_output) + :output(_output), online(false) + { + mixer_init(this, &pulse_mixer_plugin); + } }; /** @@ -59,7 +62,7 @@ pulse_mixer_quark(void) } static void -pulse_mixer_offline(struct pulse_mixer *pm) +pulse_mixer_offline(PulseMixer *pm) { if (!pm->online) return; @@ -77,7 +80,7 @@ static void pulse_mixer_volume_cb(G_GNUC_UNUSED pa_context *context, const pa_sink_input_info *i, int eol, void *userdata) { - struct pulse_mixer *pm = (struct pulse_mixer *)userdata; + PulseMixer *pm = (PulseMixer *)userdata; if (eol) return; @@ -94,7 +97,7 @@ pulse_mixer_volume_cb(G_GNUC_UNUSED pa_context *context, const pa_sink_input_inf } static void -pulse_mixer_update(struct pulse_mixer *pm, +pulse_mixer_update(PulseMixer *pm, struct pa_context *context, struct pa_stream *stream) { pa_operation *o; @@ -117,7 +120,7 @@ pulse_mixer_update(struct pulse_mixer *pm, } void -pulse_mixer_on_connect(G_GNUC_UNUSED struct pulse_mixer *pm, +pulse_mixer_on_connect(G_GNUC_UNUSED PulseMixer *pm, struct pa_context *context) { pa_operation *o; @@ -137,13 +140,13 @@ pulse_mixer_on_connect(G_GNUC_UNUSED struct pulse_mixer *pm, } void -pulse_mixer_on_disconnect(struct pulse_mixer *pm) +pulse_mixer_on_disconnect(PulseMixer *pm) { pulse_mixer_offline(pm); } void -pulse_mixer_on_change(struct pulse_mixer *pm, +pulse_mixer_on_change(PulseMixer *pm, struct pa_context *context, struct pa_stream *stream) { pulse_mixer_update(pm, context, stream); @@ -161,33 +164,27 @@ pulse_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param, return nullptr; } - struct pulse_mixer *pm = g_new(struct pulse_mixer,1); - mixer_init(&pm->base, &pulse_mixer_plugin); - - pm->online = false; - pm->output = po; + PulseMixer *pm = new PulseMixer(po); pulse_output_set_mixer(po, pm); - return &pm->base; + return pm; } static void pulse_mixer_finish(struct mixer *data) { - struct pulse_mixer *pm = (struct pulse_mixer *) data; + PulseMixer *pm = (PulseMixer *) data; pulse_output_clear_mixer(pm->output, pm); - /* free resources */ - - g_free(pm); + delete pm; } static int pulse_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r) { - struct pulse_mixer *pm = (struct pulse_mixer *) mixer; + PulseMixer *pm = (PulseMixer *) mixer; int ret; pulse_output_lock(pm->output); @@ -204,7 +201,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) { - struct pulse_mixer *pm = (struct pulse_mixer *) mixer; + PulseMixer *pm = (PulseMixer *) mixer; struct pa_cvolume cvolume; bool success; |