mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
acp: emit param change when port changed
This commit is contained in:
parent
6d41e17ca3
commit
b896d65723
4 changed files with 45 additions and 15 deletions
|
|
@ -688,7 +688,7 @@ static int mixer_callback(snd_mixer_elem_t *elem, unsigned int mask)
|
|||
if (mask == SND_CTL_EVENT_MASK_REMOVE)
|
||||
return 0;
|
||||
|
||||
pa_log_debug("%p mixer changed %d", dev, mask);
|
||||
pa_log_info("%p mixer changed %d", dev, mask);
|
||||
|
||||
if (mask & SND_CTL_EVENT_MASK_VALUE) {
|
||||
if (dev->read_volume)
|
||||
|
|
@ -715,7 +715,7 @@ static int read_volume(pa_alsa_device *dev)
|
|||
return 0;
|
||||
|
||||
dev->real_volume = r;
|
||||
pa_log_debug("New hardware volume:");
|
||||
pa_log_info("New hardware volume:");
|
||||
for (i = 0; i < r.channels; i++)
|
||||
pa_log_debug(" %d: %d", i, r.values[i]);
|
||||
|
||||
|
|
@ -792,7 +792,7 @@ static int read_mute(pa_alsa_device *dev)
|
|||
return 0;
|
||||
|
||||
dev->muted = mute;
|
||||
pa_log_debug("New muted: %d", mute);
|
||||
pa_log_info("New hardware muted: %d", mute);
|
||||
|
||||
if (impl->events && impl->events->mute_changed)
|
||||
impl->events->mute_changed(impl->user_data, &dev->device);
|
||||
|
|
@ -862,10 +862,6 @@ static void mixer_volume_init(pa_alsa_device *dev) {
|
|||
pa_log_info("Using hardware mute control.");
|
||||
dev->device.flags |= ACP_DEVICE_HW_MUTE;
|
||||
}
|
||||
if (dev->read_volume)
|
||||
dev->read_volume(dev);
|
||||
if (dev->read_mute)
|
||||
dev->read_mute(dev);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1007,6 +1003,10 @@ static int device_enable(pa_card *impl, pa_alsa_mapping *mapping, pa_alsa_device
|
|||
if (setup_mixer(impl, dev, ignore_dB) < 0)
|
||||
return -1;
|
||||
|
||||
if (dev->read_volume)
|
||||
dev->read_volume(dev);
|
||||
if (dev->read_mute)
|
||||
dev->read_mute(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1303,20 +1303,21 @@ int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
|
|||
{
|
||||
pa_alsa_device *d = (pa_alsa_device*)dev;
|
||||
pa_card *impl = d->card;
|
||||
pa_device_port *p;
|
||||
pa_device_port *p, *old = d->active_port;
|
||||
int res;
|
||||
|
||||
if (port_index >= impl->card.n_ports)
|
||||
return -EINVAL;
|
||||
|
||||
p = (pa_device_port*)impl->card.ports[port_index];
|
||||
if (p == d->active_port)
|
||||
if (p == old)
|
||||
return 0;
|
||||
|
||||
if (!pa_hashmap_get(d->ports, p->port.name))
|
||||
return -EINVAL;
|
||||
|
||||
if (d->active_port)
|
||||
d->active_port->port.flags &= ~ACP_PORT_ACTIVE;
|
||||
if (old)
|
||||
old->port.flags &= ~ACP_PORT_ACTIVE;
|
||||
d->active_port = p;
|
||||
p->port.flags |= ACP_PORT_ACTIVE;
|
||||
|
||||
|
|
@ -1328,7 +1329,7 @@ int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
|
|||
mixer_volume_init(d);
|
||||
|
||||
sync_mixer(d, p);
|
||||
return pa_alsa_ucm_set_port(d->ucm_context, p, true);
|
||||
res = pa_alsa_ucm_set_port(d->ucm_context, p, true);
|
||||
} else {
|
||||
pa_alsa_port_data *data;
|
||||
|
||||
|
|
@ -1337,6 +1338,7 @@ int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
|
|||
mixer_volume_init(d);
|
||||
|
||||
sync_mixer(d, p);
|
||||
res = 0;
|
||||
#if 0
|
||||
if (data->suspend_when_unavailable && p->available == PA_AVAILABLE_NO)
|
||||
pa_sink_suspend(s, true, PA_SUSPEND_UNAVAILABLE);
|
||||
|
|
@ -1344,7 +1346,10 @@ int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
|
|||
pa_sink_suspend(s, false, PA_SUSPEND_UNAVAILABLE);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
if (impl->events && impl->events->port_changed)
|
||||
impl->events->port_changed(impl->user_data,
|
||||
old ? old->port.index : 0, p->port.index);
|
||||
return res;
|
||||
}
|
||||
|
||||
int acp_device_set_volume(struct acp_device *dev, const float *volume, uint32_t n_volume)
|
||||
|
|
@ -1360,6 +1365,10 @@ int acp_device_set_volume(struct acp_device *dev, const float *volume, uint32_t
|
|||
for (i = 0; i < v.channels; i++)
|
||||
v.values[i] = volume[i % n_volume] * PA_VOLUME_NORM;
|
||||
|
||||
pa_log_info("Set %s volume: %d", d->set_volume ? "hardware" : "software", pa_cvolume_max(&v));
|
||||
for (i = 0; i < v.channels; i++)
|
||||
pa_log_debug(" %d: %d", i, v.values[i]);
|
||||
|
||||
if (d->set_volume) {
|
||||
d->set_volume(d, &v);
|
||||
} else {
|
||||
|
|
@ -1389,6 +1398,9 @@ int acp_device_set_mute(struct acp_device *dev, bool mute)
|
|||
pa_card *impl = d->card;
|
||||
if (d->muted == mute)
|
||||
return 0;
|
||||
|
||||
pa_log_info("Set %s mute: %d", d->set_mute ? "hardware" : "software", mute);
|
||||
|
||||
if (d->set_mute) {
|
||||
d->set_mute(d, mute);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ struct acp_card_events {
|
|||
void (*profile_available) (void *data, uint32_t index,
|
||||
enum acp_available old, enum acp_available available);
|
||||
|
||||
void (*port_changed) (void *data, uint32_t old_index, uint32_t new_index);
|
||||
|
||||
void (*port_available) (void *data, uint32_t index,
|
||||
enum acp_available old, enum acp_available available);
|
||||
|
||||
|
|
@ -144,7 +146,7 @@ struct acp_port {
|
|||
enum acp_direction direction;
|
||||
enum acp_available available;
|
||||
char *available_group; /* a string indentifier which determine the group of devices
|
||||
* handling the available state simulteneously */
|
||||
* handling the available state simultaneously */
|
||||
enum acp_port_type type;
|
||||
|
||||
struct acp_dict props;
|
||||
|
|
|
|||
|
|
@ -1144,7 +1144,7 @@ int pa_alsa_path_select(pa_alsa_path *p, pa_alsa_setting *s, snd_mixer_t *m, boo
|
|||
pa_assert(m);
|
||||
pa_assert(p);
|
||||
|
||||
pa_log_debug("Activating path %s", p->name);
|
||||
pa_log_info("Activating path %s", p->name);
|
||||
pa_alsa_path_dump(p);
|
||||
|
||||
/* First turn on hw mute if available, to avoid noise
|
||||
|
|
|
|||
|
|
@ -636,6 +636,21 @@ static void card_profile_available(void *data, uint32_t index,
|
|||
emit_info(this, false);
|
||||
}
|
||||
|
||||
static void card_port_changed(void *data, uint32_t old_index, uint32_t new_index)
|
||||
{
|
||||
struct impl *this = data;
|
||||
struct acp_card *card = this->card;
|
||||
struct acp_port *op = card->ports[old_index];
|
||||
struct acp_port *np = card->ports[new_index];
|
||||
|
||||
spa_log_info(this->log, "card port changed from %s to %s",
|
||||
op->name, np->name);
|
||||
|
||||
this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS;
|
||||
this->params[3].flags ^= SPA_PARAM_INFO_SERIAL;
|
||||
emit_info(this, false);
|
||||
}
|
||||
|
||||
static void card_port_available(void *data, uint32_t index,
|
||||
enum acp_available old, enum acp_available available)
|
||||
{
|
||||
|
|
@ -724,6 +739,7 @@ struct acp_card_events card_events = {
|
|||
.props_changed = card_props_changed,
|
||||
.profile_changed = card_profile_changed,
|
||||
.profile_available = card_profile_available,
|
||||
.port_changed = card_port_changed,
|
||||
.port_available = card_port_available,
|
||||
.volume_changed = on_volume_changed,
|
||||
.mute_changed = on_mute_changed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue