module/alsa: rename {volume,muted}_channel -> {volume,muted}_name

This commit is contained in:
Daniel Eklöf 2021-08-26 09:42:41 +02:00
parent b8dd247111
commit 7c7c4e7ce9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -19,8 +19,8 @@
struct private {
char *card;
char *mixer;
char *volume_channel;
char *muted_channel;
char *volume_name;
char *muted_name;
struct particle *label;
tll(snd_mixer_selem_channel_id_t) channels;
@ -40,8 +40,8 @@ destroy(struct module *mod)
m->label->destroy(m->label);
free(m->card);
free(m->mixer);
free(m->volume_channel);
free(m->muted_channel);
free(m->volume_name);
free(m->muted_name);
free(m);
module_default_destroy(mod);
}
@ -111,7 +111,7 @@ update_state(struct module *mod, snd_mixer_elem_t *elem)
if (max > 0) {
tll_foreach(m->channels, it) {
const char *name = snd_mixer_selem_channel_name(it->item);
if (m->volume_channel != NULL && strcmp(name, m->volume_channel) != 0)
if (m->volume_name != NULL && strcmp(name, m->volume_name) != 0)
continue;
int r = snd_mixer_selem_get_playback_volume(elem, it->item, &cur);
@ -130,7 +130,7 @@ update_state(struct module *mod, snd_mixer_elem_t *elem)
/* Get muted state */
tll_foreach(m->channels, it) {
const char *name = snd_mixer_selem_channel_name(it->item);
if (m->muted_channel != NULL && strcmp(name, m->muted_channel) != 0)
if (m->muted_name != NULL && strcmp(name, m->muted_name) != 0)
continue;
int r = snd_mixer_selem_get_playback_switch(elem, it->item, &unmuted);
@ -237,26 +237,26 @@ run_while_online(struct module *mod)
LOG_INFO("%s,%s: channels: %s", m->card, m->mixer, channels_str);
/* Verify volume/muted channel names are valid and exists */
bool volume_channel_is_valid = m->volume_channel == NULL;
bool muted_channel_is_valid = m->muted_channel == NULL;
bool volume_channel_is_valid = m->volume_name == NULL;
bool muted_channel_is_valid = m->muted_name == NULL;
tll_foreach(m->channels, it) {
const char *chan_name = snd_mixer_selem_channel_name(it->item);
if (m->volume_channel != NULL && strcmp(chan_name, m->volume_channel) == 0)
if (m->volume_name != NULL && strcmp(chan_name, m->volume_name) == 0)
volume_channel_is_valid = true;
if (m->muted_channel != NULL && strcmp(chan_name, m->muted_channel) == 0)
if (m->muted_name != NULL && strcmp(chan_name, m->muted_name) == 0)
muted_channel_is_valid = true;
}
if (!volume_channel_is_valid) {
assert(m->volume_channel != NULL);
LOG_ERR("volume: invalid channel name: %s", m->volume_channel);
assert(m->volume_name != NULL);
LOG_ERR("volume: invalid channel name: %s", m->volume_name);
goto err;
}
if (!muted_channel_is_valid) {
assert(m->muted_channel != NULL);
LOG_ERR("muted: invalid channel name: %s", m->muted_channel);
assert(m->muted_name != NULL);
LOG_ERR("muted: invalid channel name: %s", m->muted_name);
goto err;
}
@ -446,15 +446,17 @@ out:
static struct module *
alsa_new(const char *card, const char *mixer,
const char *volume_channel, const char *muted_channel,
const char *volume_channel_name, const char *muted_channel_name,
struct particle *label)
{
struct private *priv = calloc(1, sizeof(*priv));
priv->label = label;
priv->card = strdup(card);
priv->mixer = strdup(mixer);
priv->volume_channel = volume_channel != NULL ? strdup(volume_channel) : NULL;
priv->muted_channel = muted_channel != NULL ? strdup(muted_channel) : NULL;
priv->volume_name =
volume_channel_name != NULL ? strdup(volume_channel_name) : NULL;
priv->muted_name =
muted_channel_name != NULL ? strdup(muted_channel_name) : NULL;
struct module *mod = module_common_new();
mod->private = priv;