mixer_control: allow methods "open" and "close" to be NULL
It's possible to have a mixer implementation which does not explicitly need the methods open() and close().
This commit is contained in:
parent
7dd172efec
commit
ede828c910
|
@ -61,23 +61,6 @@ software_mixer_finish(struct mixer *data)
|
||||||
g_free(sm);
|
g_free(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
software_mixer_open(struct mixer *data, G_GNUC_UNUSED GError **error_r)
|
|
||||||
{
|
|
||||||
struct software_mixer *sm = (struct software_mixer *)data;
|
|
||||||
|
|
||||||
(void)sm;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
software_mixer_close(struct mixer *data)
|
|
||||||
{
|
|
||||||
struct software_mixer *sm = (struct software_mixer *)data;
|
|
||||||
|
|
||||||
(void)sm;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
software_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
|
software_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
|
||||||
{
|
{
|
||||||
|
@ -109,8 +92,6 @@ software_mixer_set_volume(struct mixer *mixer, unsigned volume,
|
||||||
const struct mixer_plugin software_mixer_plugin = {
|
const struct mixer_plugin software_mixer_plugin = {
|
||||||
.init = software_mixer_init,
|
.init = software_mixer_init,
|
||||||
.finish = software_mixer_finish,
|
.finish = software_mixer_finish,
|
||||||
.open = software_mixer_open,
|
|
||||||
.close = software_mixer_close,
|
|
||||||
.get_volume = software_mixer_get_volume,
|
.get_volume = software_mixer_get_volume,
|
||||||
.set_volume = software_mixer_set_volume,
|
.set_volume = software_mixer_set_volume,
|
||||||
.global = true,
|
.global = true,
|
||||||
|
|
|
@ -66,6 +66,8 @@ mixer_open(struct mixer *mixer, GError **error_r)
|
||||||
|
|
||||||
if (mixer->open)
|
if (mixer->open)
|
||||||
success = true;
|
success = true;
|
||||||
|
else if (mixer->plugin->open == NULL)
|
||||||
|
success = mixer->open = true;
|
||||||
else
|
else
|
||||||
success = mixer->open = mixer->plugin->open(mixer, error_r);
|
success = mixer->open = mixer->plugin->open(mixer, error_r);
|
||||||
|
|
||||||
|
@ -83,7 +85,9 @@ mixer_close_internal(struct mixer *mixer)
|
||||||
assert(mixer->plugin != NULL);
|
assert(mixer->plugin != NULL);
|
||||||
assert(mixer->open);
|
assert(mixer->open);
|
||||||
|
|
||||||
mixer->plugin->close(mixer);
|
if (mixer->plugin->close != NULL)
|
||||||
|
mixer->plugin->close(mixer);
|
||||||
|
|
||||||
mixer->open = false;
|
mixer->open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue