MixerPlugin: pass config_param reference
This commit is contained in:
parent
f54bcc1f16
commit
a0beb5fa26
@ -31,7 +31,7 @@
|
||||
|
||||
Mixer *
|
||||
mixer_new(const struct mixer_plugin *plugin, void *ao,
|
||||
const struct config_param *param,
|
||||
const config_param ¶m,
|
||||
GError **error_r)
|
||||
{
|
||||
Mixer *mixer;
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
||||
|
||||
Mixer *
|
||||
mixer_new(const struct mixer_plugin *plugin, void *ao,
|
||||
const struct config_param *param,
|
||||
const config_param ¶m,
|
||||
GError **error_r);
|
||||
|
||||
void
|
||||
|
@ -37,13 +37,12 @@ struct mixer_plugin {
|
||||
* Alocates and configures a mixer device.
|
||||
*
|
||||
* @param ao the pointer returned by audio_output_plugin.init
|
||||
* @param param the configuration section, or NULL if there is
|
||||
* no configuration
|
||||
* @param param the configuration section
|
||||
* @param error_r location to store the error occurring, or
|
||||
* NULL to ignore errors
|
||||
* @return a mixer object, or NULL on error
|
||||
*/
|
||||
Mixer *(*init)(void *ao, const struct config_param *param,
|
||||
Mixer *(*init)(void *ao, const config_param ¶m,
|
||||
GError **error_r);
|
||||
|
||||
/**
|
||||
|
@ -112,10 +112,12 @@ audio_output_load_mixer(struct audio_output *ao,
|
||||
if (plugin == NULL)
|
||||
return NULL;
|
||||
|
||||
return mixer_new(plugin, ao, ¶m, error_r);
|
||||
return mixer_new(plugin, ao, param, error_r);
|
||||
|
||||
case MIXER_TYPE_SOFTWARE:
|
||||
mixer = mixer_new(&software_mixer_plugin, NULL, NULL, NULL);
|
||||
mixer = mixer_new(&software_mixer_plugin, nullptr,
|
||||
config_param(),
|
||||
nullptr);
|
||||
assert(mixer != NULL);
|
||||
|
||||
filter_chain_append(filter_chain, "software_mixer",
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#define VOLUME_MIXER_ALSA_DEFAULT "default"
|
||||
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
|
||||
#define VOLUME_MIXER_ALSA_INDEX_DEFAULT 0
|
||||
static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0;
|
||||
|
||||
class AlsaMixerMonitor final : private MultiSocketMonitor {
|
||||
snd_mixer_t *const mixer;
|
||||
@ -61,7 +61,7 @@ class AlsaMixer final : public Mixer {
|
||||
public:
|
||||
AlsaMixer():Mixer(alsa_mixer_plugin) {}
|
||||
|
||||
void Configure(const config_param *param);
|
||||
void Configure(const config_param ¶m);
|
||||
bool Setup(GError **error_r);
|
||||
bool Open(GError **error_r);
|
||||
void Close();
|
||||
@ -138,18 +138,18 @@ alsa_mixer_elem_callback(G_GNUC_UNUSED snd_mixer_elem_t *elem, unsigned mask)
|
||||
*/
|
||||
|
||||
inline void
|
||||
AlsaMixer::Configure(const config_param *param)
|
||||
AlsaMixer::Configure(const config_param ¶m)
|
||||
{
|
||||
device = config_get_block_string(param, "mixer_device",
|
||||
VOLUME_MIXER_ALSA_DEFAULT);
|
||||
control = config_get_block_string(param, "mixer_control",
|
||||
VOLUME_MIXER_ALSA_CONTROL_DEFAULT);
|
||||
index = config_get_block_unsigned(param, "mixer_index",
|
||||
VOLUME_MIXER_ALSA_INDEX_DEFAULT);
|
||||
device = param.GetBlockValue("mixer_device",
|
||||
VOLUME_MIXER_ALSA_DEFAULT);
|
||||
control = param.GetBlockValue("mixer_control",
|
||||
VOLUME_MIXER_ALSA_CONTROL_DEFAULT);
|
||||
index = param.GetBlockValue("mixer_index",
|
||||
VOLUME_MIXER_ALSA_INDEX_DEFAULT);
|
||||
}
|
||||
|
||||
static Mixer *
|
||||
alsa_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
|
||||
alsa_mixer_init(G_GNUC_UNUSED void *ao, const config_param ¶m,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
AlsaMixer *am = new AlsaMixer();
|
||||
|
@ -51,7 +51,7 @@ class OssMixer : public Mixer {
|
||||
public:
|
||||
OssMixer():Mixer(oss_mixer_plugin) {}
|
||||
|
||||
bool Configure(const config_param *param, GError **error_r);
|
||||
bool Configure(const config_param ¶m, GError **error_r);
|
||||
bool Open(GError **error_r);
|
||||
void Close();
|
||||
|
||||
@ -84,11 +84,11 @@ oss_find_mixer(const char *name)
|
||||
}
|
||||
|
||||
inline bool
|
||||
OssMixer::Configure(const config_param *param, GError **error_r)
|
||||
OssMixer::Configure(const config_param ¶m, GError **error_r)
|
||||
{
|
||||
device = config_get_block_string(param, "mixer_device",
|
||||
device = param.GetBlockValue("mixer_device",
|
||||
VOLUME_MIXER_OSS_DEFAULT);
|
||||
control = config_get_block_string(param, "mixer_control", NULL);
|
||||
control = param.GetBlockValue("mixer_control");
|
||||
|
||||
if (control != NULL) {
|
||||
volume_control = oss_find_mixer(control);
|
||||
@ -104,7 +104,7 @@ OssMixer::Configure(const config_param *param, GError **error_r)
|
||||
}
|
||||
|
||||
static Mixer *
|
||||
oss_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
|
||||
oss_mixer_init(G_GNUC_UNUSED void *ao, const config_param ¶m,
|
||||
GError **error_r)
|
||||
{
|
||||
OssMixer *om = new OssMixer();
|
||||
|
@ -153,7 +153,7 @@ pulse_mixer_on_change(PulseMixer *pm,
|
||||
}
|
||||
|
||||
static Mixer *
|
||||
pulse_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
|
||||
pulse_mixer_init(void *ao, gcc_unused const config_param ¶m,
|
||||
GError **error_r)
|
||||
{
|
||||
PulseOutput *po = (PulseOutput *)ao;
|
||||
|
@ -34,7 +34,7 @@ struct RoarMixer final : public Mixer {
|
||||
};
|
||||
|
||||
static Mixer *
|
||||
roar_mixer_init(void *ao, gcc_unused const struct config_param *param,
|
||||
roar_mixer_init(void *ao, gcc_unused const config_param ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new RoarMixer((RoarOutput *)ao);
|
||||
|
@ -51,7 +51,7 @@ struct SoftwareMixer final : public Mixer {
|
||||
|
||||
static Mixer *
|
||||
software_mixer_init(gcc_unused void *ao,
|
||||
gcc_unused const struct config_param *param,
|
||||
gcc_unused const config_param ¶m,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
return new SoftwareMixer();
|
||||
|
@ -60,7 +60,7 @@ winmm_volume_encode(int volume)
|
||||
}
|
||||
|
||||
static Mixer *
|
||||
winmm_mixer_init(void *ao, G_GNUC_UNUSED const struct config_param *param,
|
||||
winmm_mixer_init(void *ao, gcc_unused const config_param ¶m,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
assert(ao != nullptr);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "GlobalEvents.hxx"
|
||||
#include "Main.hxx"
|
||||
#include "event/Loop.hxx"
|
||||
#include "ConfigData.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@ -125,7 +126,8 @@ int main(int argc, G_GNUC_UNUSED char **argv)
|
||||
|
||||
main_loop = new EventLoop(EventLoop::Default());
|
||||
|
||||
Mixer *mixer = mixer_new(&alsa_mixer_plugin, NULL, NULL, &error);
|
||||
Mixer *mixer = mixer_new(&alsa_mixer_plugin, nullptr,
|
||||
config_param(), &error);
|
||||
if (mixer == NULL) {
|
||||
g_printerr("mixer_new() failed: %s\n", error->message);
|
||||
g_error_free(error);
|
||||
|
Loading…
Reference in New Issue
Block a user