Commit d3e1b72d authored by Max Kellermann's avatar Max Kellermann

mixer/{alsa,pulse}: convert to C++

parent b5e1bd57
......@@ -101,7 +101,6 @@ mpd_headers = \
src/mixer_plugin.h \
src/mixer_type.h \
src/mixer/software_mixer_plugin.h \
src/mixer/pulse_mixer_plugin.h \
src/daemon.h \
src/AudioCompress/config.h \
src/AudioCompress/compress.h \
......@@ -812,7 +811,7 @@ libmixer_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \
if HAVE_ALSA
liboutput_plugins_a_SOURCES += \
src/output/alsa_output_plugin.c src/output/alsa_output_plugin.h
libmixer_plugins_a_SOURCES += src/mixer/alsa_mixer_plugin.c
libmixer_plugins_a_SOURCES += src/mixer/AlsaMixerPlugin.cxx
endif
if HAVE_ROAR
......@@ -870,7 +869,8 @@ endif
if HAVE_PULSE
liboutput_plugins_a_SOURCES += \
src/output/pulse_output_plugin.c src/output/pulse_output_plugin.h
libmixer_plugins_a_SOURCES += src/mixer/pulse_mixer_plugin.c
libmixer_plugins_a_SOURCES += \
src/mixer/PulseMixerPlugin.cxx src/mixer/PulseMixerPlugin.h
endif
if HAVE_SHOUT
......
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* 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
......@@ -77,7 +77,7 @@ find_fd(GSList **list_r, int fd)
if (list == NULL)
return NULL;
GPollFD *p = list->data;
GPollFD *p = (GPollFD *)list->data;
if (p->fd == fd)
return list_r;
......@@ -103,7 +103,7 @@ alsa_mixer_update_fd(struct alsa_mixer_source *source, const struct pollfd *p,
GSList *found = *found_r;
*found_r = found->next;
GPollFD *q = found->data;
GPollFD *q = (GPollFD *)found->data;
if (q->events != p->events) {
/* refresh events */
g_source_remove_poll(&source->source, q);
......@@ -135,7 +135,7 @@ alsa_mixer_update_fds(struct alsa_mixer_source *source)
g_free(pfds);
for (; old != NULL; old = old->next) {
GPollFD *q = old->data;
GPollFD *q = (GPollFD *)old->data;
g_source_remove_poll(&source->source, q);
g_free(q);
}
......@@ -163,7 +163,7 @@ alsa_mixer_source_check(GSource *_source)
struct alsa_mixer_source *source = (struct alsa_mixer_source *)_source;
for (const GSList *i = source->fds; i != NULL; i = i->next) {
const GPollFD *poll_fd = i->data;
const GPollFD *poll_fd = (GPollFD *)i->data;
if (poll_fd->revents != 0)
return true;
}
......@@ -194,10 +194,12 @@ alsa_mixer_source_finalize(GSource *_source)
}
static GSourceFuncs alsa_mixer_source_funcs = {
.prepare = alsa_mixer_source_prepare,
.check = alsa_mixer_source_check,
.dispatch = alsa_mixer_source_dispatch,
.finalize = alsa_mixer_source_finalize,
alsa_mixer_source_prepare,
alsa_mixer_source_check,
alsa_mixer_source_dispatch,
alsa_mixer_source_finalize,
nullptr,
nullptr,
};
/*
......@@ -421,11 +423,11 @@ alsa_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
}
const struct mixer_plugin alsa_mixer_plugin = {
.init = alsa_mixer_init,
.finish = alsa_mixer_finish,
.open = alsa_mixer_open,
.close = alsa_mixer_close,
.get_volume = alsa_mixer_get_volume,
.set_volume = alsa_mixer_set_volume,
.global = true,
alsa_mixer_init,
alsa_mixer_finish,
alsa_mixer_open,
alsa_mixer_close,
alsa_mixer_get_volume,
alsa_mixer_set_volume,
true,
};
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* 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
......@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "pulse_mixer_plugin.h"
#include "PulseMixerPlugin.h"
#include "mixer_api.h"
#include "output/pulse_output_plugin.h"
#include "conf.h"
......@@ -77,7 +77,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 = userdata;
struct pulse_mixer *pm = (struct pulse_mixer *)userdata;
if (eol)
return;
......@@ -153,16 +153,15 @@ static struct mixer *
pulse_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
GError **error_r)
{
struct pulse_mixer *pm;
struct pulse_output *po = ao;
struct pulse_output *po = (struct pulse_output *)ao;
if (ao == NULL) {
g_set_error(error_r, pulse_mixer_quark(), 0,
"The pulse mixer cannot work without the audio output");
return false;
return nullptr;
}
pm = g_new(struct pulse_mixer,1);
struct pulse_mixer *pm = g_new(struct pulse_mixer,1);
mixer_init(&pm->base, &pulse_mixer_plugin);
pm->online = false;
......@@ -229,8 +228,11 @@ pulse_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
}
const struct mixer_plugin pulse_mixer_plugin = {
.init = pulse_mixer_init,
.finish = pulse_mixer_finish,
.get_volume = pulse_mixer_get_volume,
.set_volume = pulse_mixer_set_volume,
pulse_mixer_init,
pulse_mixer_finish,
nullptr,
nullptr,
pulse_mixer_get_volume,
pulse_mixer_set_volume,
false,
};
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* 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
......@@ -26,6 +26,10 @@ struct pulse_mixer;
struct pa_context;
struct pa_stream;
#ifdef __cplusplus
extern "C" {
#endif
void
pulse_mixer_on_connect(struct pulse_mixer *pm, struct pa_context *context);
......@@ -36,4 +40,8 @@ void
pulse_mixer_on_change(struct pulse_mixer *pm,
struct pa_context *context, struct pa_stream *stream);
#ifdef __cplusplus
}
#endif
#endif
......@@ -46,7 +46,15 @@ struct mixer {
bool failed;
};
#ifdef __cplusplus
extern "C" {
#endif
void
mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin);
#ifdef __cplusplus
}
#endif
#endif
......@@ -21,7 +21,7 @@
#include "pulse_output_plugin.h"
#include "output_api.h"
#include "mixer_list.h"
#include "mixer/pulse_mixer_plugin.h"
#include "mixer/PulseMixerPlugin.h"
#include <glib.h>
......
......@@ -30,6 +30,10 @@ struct pa_cvolume;
extern const struct audio_output_plugin pulse_output_plugin;
#ifdef __cplusplus
extern "C" {
#endif
void
pulse_output_lock(struct pulse_output *po);
......@@ -46,4 +50,8 @@ bool
pulse_output_set_volume(struct pulse_output *po,
const struct pa_cvolume *volume, GError **error_r);
#ifdef __cplusplus
}
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment