mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
alsa: Move UCM port availability updating to the mixer code
Previously module-alsa-card assigned to pa_alsa_jack.plugged_in directly, and then did the port availability updating manually. The idea of pa_alsa_jack_set_plugged_in() is to move the availability updating to the mixer infrastructure, where it really belongs. Similarly, pa_alsa_jack.has_control was previously modified directly from several places. The has_control field affects the port availability, and pa_alsa_jack_set_has_control() takes care of updating the availability. For now, pa_alsa_jack_set_plugged_in() and pa_alsa_jack_set_has_control() only update the port availability when using UCM. My plan is to adapt the traditional mixer code later.
This commit is contained in:
parent
40714b6bcc
commit
c9557e6969
6 changed files with 112 additions and 17 deletions
|
|
@ -378,16 +378,17 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
|
|||
|
||||
PA_HASHMAP_FOREACH(jack, u->jacks, state)
|
||||
if (jack->melem == melem) {
|
||||
jack->plugged_in = plugged_in;
|
||||
pa_alsa_jack_set_plugged_in(jack, plugged_in);
|
||||
|
||||
if (u->use_ucm) {
|
||||
pa_assert(u->card->ports);
|
||||
port = pa_hashmap_get(u->card->ports, jack->name);
|
||||
pa_assert(port);
|
||||
}
|
||||
else {
|
||||
pa_assert(jack->path);
|
||||
pa_assert_se(port = jack->path->port);
|
||||
/* When using UCM, pa_alsa_jack_set_plugged_in() maps the jack
|
||||
* state to port availability. */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* When not using UCM, we have to do the jack state -> port
|
||||
* availability mapping ourselves. */
|
||||
pa_assert_se(port = jack->path->port);
|
||||
report_port_state(port, u);
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -515,7 +516,7 @@ static void init_jacks(struct userdata *u) {
|
|||
jack->melem = pa_alsa_mixer_find(u->mixer_handle, jack->alsa_name, 0);
|
||||
if (!jack->melem) {
|
||||
pa_log_warn("Jack '%s' seems to have disappeared.", jack->alsa_name);
|
||||
jack->has_control = false;
|
||||
pa_alsa_jack_set_has_control(jack, false);
|
||||
continue;
|
||||
}
|
||||
snd_mixer_elem_set_callback(jack->melem, report_jack_state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue