mixer/winmm: convert to a class
This commit is contained in:
parent
506c716cf2
commit
621467717d
@ -31,9 +31,13 @@
|
|||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "winmm_mixer"
|
#define G_LOG_DOMAIN "winmm_mixer"
|
||||||
|
|
||||||
struct winmm_mixer {
|
struct WinmmMixer final : public mixer {
|
||||||
struct mixer base;
|
|
||||||
WinmmOutput *output;
|
WinmmOutput *output;
|
||||||
|
|
||||||
|
WinmmMixer(WinmmOutput *_output)
|
||||||
|
:output(_output) {
|
||||||
|
mixer_init(this, &winmm_mixer_plugin);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline GQuark
|
static inline GQuark
|
||||||
@ -61,23 +65,21 @@ winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
|
|||||||
{
|
{
|
||||||
assert(ao != nullptr);
|
assert(ao != nullptr);
|
||||||
|
|
||||||
struct winmm_mixer *wm = g_new(struct winmm_mixer, 1);
|
return new WinmmMixer((WinmmOutput *)ao);
|
||||||
mixer_init(&wm->base, &winmm_mixer_plugin);
|
|
||||||
wm->output = (WinmmOutput *) ao;
|
|
||||||
|
|
||||||
return &wm->base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
winmm_mixer_finish(struct mixer *data)
|
winmm_mixer_finish(struct mixer *data)
|
||||||
{
|
{
|
||||||
g_free(data);
|
WinmmMixer *wm = (WinmmMixer *)data;
|
||||||
|
|
||||||
|
delete wm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
winmm_mixer_get_volume(struct mixer *mixer, GError **error_r)
|
winmm_mixer_get_volume(struct mixer *mixer, GError **error_r)
|
||||||
{
|
{
|
||||||
struct winmm_mixer *wm = (struct winmm_mixer *) mixer;
|
WinmmMixer *wm = (WinmmMixer *) mixer;
|
||||||
DWORD volume;
|
DWORD volume;
|
||||||
HWAVEOUT handle = winmm_output_get_handle(wm->output);
|
HWAVEOUT handle = winmm_output_get_handle(wm->output);
|
||||||
MMRESULT result = waveOutGetVolume(handle, &volume);
|
MMRESULT result = waveOutGetVolume(handle, &volume);
|
||||||
@ -94,7 +96,7 @@ winmm_mixer_get_volume(struct mixer *mixer, GError **error_r)
|
|||||||
static bool
|
static bool
|
||||||
winmm_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
|
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);
|
DWORD value = winmm_volume_encode(volume);
|
||||||
HWAVEOUT handle = winmm_output_get_handle(wm->output);
|
HWAVEOUT handle = winmm_output_get_handle(wm->output);
|
||||||
MMRESULT result = waveOutSetVolume(handle, value);
|
MMRESULT result = waveOutSetVolume(handle, value);
|
||||||
|
Loading…
Reference in New Issue
Block a user