mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-25 05:15:41 +02:00
module/alsa: handle failure(s) to attach to card or find mixer
This commit is contained in:
parent
fbb6cd47c4
commit
cffb007009
1 changed files with 22 additions and 5 deletions
|
@ -178,18 +178,32 @@ static int
|
||||||
run(struct module *mod)
|
run(struct module *mod)
|
||||||
{
|
{
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
snd_mixer_t *handle;
|
snd_mixer_t *handle;
|
||||||
snd_mixer_open(&handle, 0);
|
if (snd_mixer_open(&handle, 0) != 0) {
|
||||||
snd_mixer_attach(handle, m->card);
|
LOG_ERR("failed to open handle");
|
||||||
snd_mixer_selem_register(handle, NULL, NULL);
|
return 1;
|
||||||
snd_mixer_load(handle);
|
}
|
||||||
|
|
||||||
|
if (snd_mixer_attach(handle, m->card) != 0 ||
|
||||||
|
snd_mixer_selem_register(handle, NULL, NULL) != 0 ||
|
||||||
|
snd_mixer_load(handle) != 0)
|
||||||
|
{
|
||||||
|
LOG_ERR("failed to attach to card");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
snd_mixer_selem_id_t *sid;
|
snd_mixer_selem_id_t *sid;
|
||||||
snd_mixer_selem_id_alloca(&sid);
|
snd_mixer_selem_id_alloca(&sid);
|
||||||
snd_mixer_selem_id_set_index(sid, 0);
|
snd_mixer_selem_id_set_index(sid, 0);
|
||||||
snd_mixer_selem_id_set_name(sid, m->mixer);
|
snd_mixer_selem_id_set_name(sid, m->mixer);
|
||||||
|
|
||||||
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
|
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
|
||||||
|
if (elem == NULL) {
|
||||||
|
LOG_ERR("failed to find mixer");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get available channels */
|
/* Get available channels */
|
||||||
for (size_t i = 0; i < SND_MIXER_SCHN_LAST; i++) {
|
for (size_t i = 0; i < SND_MIXER_SCHN_LAST; i++) {
|
||||||
|
@ -243,9 +257,12 @@ run(struct module *mod)
|
||||||
update_state(mod, elem);
|
update_state(mod, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
err:
|
||||||
snd_mixer_close(handle);
|
snd_mixer_close(handle);
|
||||||
snd_config_update_free_global();
|
snd_config_update_free_global();
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct module *
|
static struct module *
|
||||||
|
|
Loading…
Add table
Reference in a new issue