mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-22 12:25:38 +02:00
module/alsa: rename {volume,muted}_channel -> {volume,muted}_name
This commit is contained in:
parent
b8dd247111
commit
7c7c4e7ce9
1 changed files with 19 additions and 17 deletions
|
@ -19,8 +19,8 @@
|
||||||
struct private {
|
struct private {
|
||||||
char *card;
|
char *card;
|
||||||
char *mixer;
|
char *mixer;
|
||||||
char *volume_channel;
|
char *volume_name;
|
||||||
char *muted_channel;
|
char *muted_name;
|
||||||
struct particle *label;
|
struct particle *label;
|
||||||
|
|
||||||
tll(snd_mixer_selem_channel_id_t) channels;
|
tll(snd_mixer_selem_channel_id_t) channels;
|
||||||
|
@ -40,8 +40,8 @@ destroy(struct module *mod)
|
||||||
m->label->destroy(m->label);
|
m->label->destroy(m->label);
|
||||||
free(m->card);
|
free(m->card);
|
||||||
free(m->mixer);
|
free(m->mixer);
|
||||||
free(m->volume_channel);
|
free(m->volume_name);
|
||||||
free(m->muted_channel);
|
free(m->muted_name);
|
||||||
free(m);
|
free(m);
|
||||||
module_default_destroy(mod);
|
module_default_destroy(mod);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ update_state(struct module *mod, snd_mixer_elem_t *elem)
|
||||||
if (max > 0) {
|
if (max > 0) {
|
||||||
tll_foreach(m->channels, it) {
|
tll_foreach(m->channels, it) {
|
||||||
const char *name = snd_mixer_selem_channel_name(it->item);
|
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;
|
continue;
|
||||||
|
|
||||||
int r = snd_mixer_selem_get_playback_volume(elem, it->item, &cur);
|
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 */
|
/* Get muted state */
|
||||||
tll_foreach(m->channels, it) {
|
tll_foreach(m->channels, it) {
|
||||||
const char *name = snd_mixer_selem_channel_name(it->item);
|
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;
|
continue;
|
||||||
|
|
||||||
int r = snd_mixer_selem_get_playback_switch(elem, it->item, &unmuted);
|
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);
|
LOG_INFO("%s,%s: channels: %s", m->card, m->mixer, channels_str);
|
||||||
|
|
||||||
/* Verify volume/muted channel names are valid and exists */
|
/* Verify volume/muted channel names are valid and exists */
|
||||||
bool volume_channel_is_valid = m->volume_channel == NULL;
|
bool volume_channel_is_valid = m->volume_name == NULL;
|
||||||
bool muted_channel_is_valid = m->muted_channel == NULL;
|
bool muted_channel_is_valid = m->muted_name == NULL;
|
||||||
|
|
||||||
tll_foreach(m->channels, it) {
|
tll_foreach(m->channels, it) {
|
||||||
const char *chan_name = snd_mixer_selem_channel_name(it->item);
|
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;
|
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;
|
muted_channel_is_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!volume_channel_is_valid) {
|
if (!volume_channel_is_valid) {
|
||||||
assert(m->volume_channel != NULL);
|
assert(m->volume_name != NULL);
|
||||||
LOG_ERR("volume: invalid channel name: %s", m->volume_channel);
|
LOG_ERR("volume: invalid channel name: %s", m->volume_name);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!muted_channel_is_valid) {
|
if (!muted_channel_is_valid) {
|
||||||
assert(m->muted_channel != NULL);
|
assert(m->muted_name != NULL);
|
||||||
LOG_ERR("muted: invalid channel name: %s", m->muted_channel);
|
LOG_ERR("muted: invalid channel name: %s", m->muted_name);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,15 +446,17 @@ out:
|
||||||
|
|
||||||
static struct module *
|
static struct module *
|
||||||
alsa_new(const char *card, const char *mixer,
|
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 particle *label)
|
||||||
{
|
{
|
||||||
struct private *priv = calloc(1, sizeof(*priv));
|
struct private *priv = calloc(1, sizeof(*priv));
|
||||||
priv->label = label;
|
priv->label = label;
|
||||||
priv->card = strdup(card);
|
priv->card = strdup(card);
|
||||||
priv->mixer = strdup(mixer);
|
priv->mixer = strdup(mixer);
|
||||||
priv->volume_channel = volume_channel != NULL ? strdup(volume_channel) : NULL;
|
priv->volume_name =
|
||||||
priv->muted_channel = muted_channel != NULL ? strdup(muted_channel) : NULL;
|
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();
|
struct module *mod = module_common_new();
|
||||||
mod->private = priv;
|
mod->private = priv;
|
||||||
|
|
Loading…
Add table
Reference in a new issue