mixer_plugin: pass audio_output pointer to mixer_plugin.init()
This allows the mixer object to access its associated audio output object.
This commit is contained in:
parent
b8ccc885c8
commit
ac32f36e4e
@ -52,7 +52,7 @@ alsa_mixer_quark(void)
|
||||
}
|
||||
|
||||
static struct mixer *
|
||||
alsa_mixer_init(const struct config_param *param,
|
||||
alsa_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
struct alsa_mixer *am = g_new(struct alsa_mixer, 1);
|
||||
|
@ -74,7 +74,8 @@ oss_find_mixer(const char *name)
|
||||
}
|
||||
|
||||
static struct mixer *
|
||||
oss_mixer_init(const struct config_param *param, GError **error_r)
|
||||
oss_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
|
||||
GError **error_r)
|
||||
{
|
||||
struct oss_mixer *om = g_new(struct oss_mixer, 1);
|
||||
|
||||
|
@ -212,7 +212,7 @@ context_state_cb(pa_context *context, void *userdata)
|
||||
|
||||
|
||||
static struct mixer *
|
||||
pulse_mixer_init(const struct config_param *param,
|
||||
pulse_mixer_init(G_GNUC_UNUSED void *ao, const struct config_param *param,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
struct pulse_mixer *pm = g_new(struct pulse_mixer,1);
|
||||
|
@ -37,7 +37,8 @@ struct software_mixer {
|
||||
};
|
||||
|
||||
static struct mixer *
|
||||
software_mixer_init(G_GNUC_UNUSED const struct config_param *param,
|
||||
software_mixer_init(G_GNUC_UNUSED void *ao,
|
||||
G_GNUC_UNUSED const struct config_param *param,
|
||||
G_GNUC_UNUSED GError **error_r)
|
||||
{
|
||||
struct software_mixer *sm = g_new(struct software_mixer, 1);
|
||||
|
@ -27,14 +27,15 @@
|
||||
#define G_LOG_DOMAIN "mixer"
|
||||
|
||||
struct mixer *
|
||||
mixer_new(const struct mixer_plugin *plugin, const struct config_param *param,
|
||||
mixer_new(const struct mixer_plugin *plugin, void *ao,
|
||||
const struct config_param *param,
|
||||
GError **error_r)
|
||||
{
|
||||
struct mixer *mixer;
|
||||
|
||||
assert(plugin != NULL);
|
||||
|
||||
mixer = plugin->init(param, error_r);
|
||||
mixer = plugin->init(ao, param, error_r);
|
||||
|
||||
assert(mixer == NULL || mixer->plugin == plugin);
|
||||
|
||||
|
@ -34,7 +34,8 @@ struct mixer_plugin;
|
||||
struct config_param;
|
||||
|
||||
struct mixer *
|
||||
mixer_new(const struct mixer_plugin *plugin, const struct config_param *param,
|
||||
mixer_new(const struct mixer_plugin *plugin, void *ao,
|
||||
const struct config_param *param,
|
||||
GError **error_r);
|
||||
|
||||
void
|
||||
|
@ -38,11 +38,14 @@ 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 error_r location to store the error occuring, or
|
||||
* NULL to ignore errors
|
||||
* @return a mixer object, or NULL on error
|
||||
*/
|
||||
struct mixer *(*init)(const struct config_param *param,
|
||||
struct mixer *(*init)(void *ao, const struct config_param *param,
|
||||
GError **error_r);
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ audio_output_mixer_type(const struct config_param *param)
|
||||
}
|
||||
|
||||
static struct mixer *
|
||||
audio_output_load_mixer(const struct config_param *param,
|
||||
audio_output_load_mixer(void *ao, const struct config_param *param,
|
||||
const struct mixer_plugin *plugin,
|
||||
struct filter *filter_chain,
|
||||
GError **error_r)
|
||||
@ -105,10 +105,10 @@ audio_output_load_mixer(const struct config_param *param,
|
||||
if (plugin == NULL)
|
||||
return NULL;
|
||||
|
||||
return mixer_new(plugin, param, error_r);
|
||||
return mixer_new(plugin, ao, param, error_r);
|
||||
|
||||
case MIXER_TYPE_SOFTWARE:
|
||||
mixer = mixer_new(&software_mixer_plugin, NULL, NULL);
|
||||
mixer = mixer_new(&software_mixer_plugin, NULL, NULL, NULL);
|
||||
assert(mixer != NULL);
|
||||
|
||||
filter_chain_append(filter_chain,
|
||||
@ -200,7 +200,8 @@ audio_output_init(struct audio_output *ao, const struct config_param *param,
|
||||
if (ao->data == NULL)
|
||||
return false;
|
||||
|
||||
ao->mixer = audio_output_load_mixer(param, plugin->mixer_plugin,
|
||||
ao->mixer = audio_output_load_mixer(ao->data, param,
|
||||
plugin->mixer_plugin,
|
||||
ao->filter, &error);
|
||||
if (ao->mixer == NULL && error != NULL) {
|
||||
g_warning("Failed to initialize hardware mixer for '%s': %s",
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, G_GNUC_UNUSED char **argv)
|
||||
|
||||
g_thread_init(NULL);
|
||||
|
||||
mixer = mixer_new(&alsa_mixer_plugin, NULL, &error);
|
||||
mixer = mixer_new(&alsa_mixer_plugin, NULL, NULL, &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