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