diff options
author | Max Kellermann <max@duempel.org> | 2013-04-16 21:31:03 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-04-16 21:31:03 +0200 |
commit | 621467717d93221a63c9234d4273d9629635c30f (patch) | |
tree | 99f4083224af63e791937b3b6ae6f85a6d33c46e /src/mixer/WinmmMixerPlugin.cxx | |
parent | 506c716cf231182fa2ce9b791963f07c6b27036d (diff) | |
download | mpd-621467717d93221a63c9234d4273d9629635c30f.tar.gz mpd-621467717d93221a63c9234d4273d9629635c30f.tar.xz mpd-621467717d93221a63c9234d4273d9629635c30f.zip |
mixer/winmm: convert to a class
Diffstat (limited to 'src/mixer/WinmmMixerPlugin.cxx')
-rw-r--r-- | src/mixer/WinmmMixerPlugin.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mixer/WinmmMixerPlugin.cxx b/src/mixer/WinmmMixerPlugin.cxx index bf3155864..bca14f51f 100644 --- a/src/mixer/WinmmMixerPlugin.cxx +++ b/src/mixer/WinmmMixerPlugin.cxx @@ -31,9 +31,13 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "winmm_mixer" -struct winmm_mixer { - struct mixer base; +struct WinmmMixer final : public mixer { WinmmOutput *output; + + WinmmMixer(WinmmOutput *_output) + :output(_output) { + mixer_init(this, &winmm_mixer_plugin); + } }; static inline GQuark @@ -61,23 +65,21 @@ winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param, { assert(ao != nullptr); - struct winmm_mixer *wm = g_new(struct winmm_mixer, 1); - mixer_init(&wm->base, &winmm_mixer_plugin); - wm->output = (WinmmOutput *) ao; - - return &wm->base; + return new WinmmMixer((WinmmOutput *)ao); } static void winmm_mixer_finish(struct mixer *data) { - g_free(data); + WinmmMixer *wm = (WinmmMixer *)data; + + delete wm; } static int winmm_mixer_get_volume(struct mixer *mixer, GError **error_r) { - struct winmm_mixer *wm = (struct winmm_mixer *) mixer; + WinmmMixer *wm = (WinmmMixer *) mixer; DWORD volume; HWAVEOUT handle = winmm_output_get_handle(wm->output); MMRESULT result = waveOutGetVolume(handle, &volume); @@ -94,7 +96,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) { - struct winmm_mixer *wm = (struct winmm_mixer *) mixer; + WinmmMixer *wm = (WinmmMixer *) mixer; DWORD value = winmm_volume_encode(volume); HWAVEOUT handle = winmm_output_get_handle(wm->output); MMRESULT result = waveOutSetVolume(handle, value); |