mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
acp: remove the soft volume/mute events
Remove the soft mute/volume events, add a new method to get the soft volume and use the volume_changed event to emit the changed soft and monitor (real) volumes event for the node. Make sure the monitor ports always uses the monitor volume, which is the real volume unaffected by the mixer volumes. This configures the soft and real volume on the sink/source in all cases and makes the monitor port follow the real volume of the sink. See #897
This commit is contained in:
parent
3bce026d67
commit
5cddd61c6c
4 changed files with 42 additions and 54 deletions
|
|
@ -778,31 +778,24 @@ static void card_port_available(void *data, uint32_t index,
|
|||
}
|
||||
|
||||
static void on_volume_changed(void *data, struct acp_device *dev)
|
||||
{
|
||||
struct impl *this = data;
|
||||
spa_log_info(this->log, "device %s volume changed", dev->name);
|
||||
this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS;
|
||||
this->params[IDX_Route].user++;
|
||||
}
|
||||
|
||||
static void on_mute_changed(void *data, struct acp_device *dev)
|
||||
{
|
||||
struct impl *this = data;
|
||||
spa_log_info(this->log, "device %s mute changed", dev->name);
|
||||
this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS;
|
||||
this->params[IDX_Route].user++;
|
||||
}
|
||||
|
||||
static void on_set_soft_volume(void *data, struct acp_device *dev,
|
||||
const float *volume, uint32_t n_volume)
|
||||
{
|
||||
struct impl *this = data;
|
||||
struct spa_event *event;
|
||||
uint8_t buffer[4096];
|
||||
struct spa_pod_builder b = { 0 };
|
||||
struct spa_pod_frame f[1];
|
||||
uint32_t n_volume = dev->format.channels;
|
||||
float volume[n_volume];
|
||||
float mon_volume[n_volume];
|
||||
|
||||
spa_log_info(this->log, "device %s soft volume %f", dev->name, volume[0]);
|
||||
spa_log_info(this->log, "device %s volume changed", dev->name);
|
||||
this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS;
|
||||
this->params[IDX_Route].user++;
|
||||
|
||||
spa_zero(volume);
|
||||
spa_zero(mon_volume);
|
||||
acp_device_get_soft_volume(dev, volume, n_volume);
|
||||
acp_device_get_volume(dev, mon_volume, n_volume);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_push_object(&b, &f[0],
|
||||
|
|
@ -814,6 +807,8 @@ static void on_set_soft_volume(void *data, struct acp_device *dev,
|
|||
SPA_TYPE_OBJECT_Props, SPA_EVENT_DEVICE_Props,
|
||||
SPA_PROP_channelVolumes, SPA_POD_Array(sizeof(float),
|
||||
SPA_TYPE_Float, n_volume, volume),
|
||||
SPA_PROP_monitorVolumes, SPA_POD_Array(sizeof(float),
|
||||
SPA_TYPE_Float, n_volume, mon_volume),
|
||||
SPA_PROP_channelMap, SPA_POD_Array(sizeof(uint32_t),
|
||||
SPA_TYPE_Id, dev->format.channels,
|
||||
dev->format.map));
|
||||
|
|
@ -822,16 +817,20 @@ static void on_set_soft_volume(void *data, struct acp_device *dev,
|
|||
spa_device_emit_event(&this->hooks, event);
|
||||
}
|
||||
|
||||
static void on_set_soft_mute(void *data, struct acp_device *dev,
|
||||
bool mute)
|
||||
static void on_mute_changed(void *data, struct acp_device *dev)
|
||||
{
|
||||
struct impl *this = data;
|
||||
struct spa_event *event;
|
||||
uint8_t buffer[4096];
|
||||
struct spa_pod_builder b = { 0 };
|
||||
struct spa_pod_frame f[1];
|
||||
bool mute;
|
||||
|
||||
spa_log_info(this->log, "device %s soft mute %d", dev->name, mute);
|
||||
spa_log_info(this->log, "device %s mute changed", dev->name);
|
||||
this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS;
|
||||
this->params[IDX_Route].user++;
|
||||
|
||||
acp_device_get_mute(dev, &mute);
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_push_object(&b, &f[0],
|
||||
|
|
@ -842,7 +841,8 @@ static void on_set_soft_mute(void *data, struct acp_device *dev,
|
|||
|
||||
spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_Props, SPA_EVENT_DEVICE_Props,
|
||||
SPA_PROP_mute, SPA_POD_Bool(mute));
|
||||
SPA_PROP_mute, SPA_POD_Bool(mute),
|
||||
SPA_PROP_monitorMute, SPA_POD_Bool(mute));
|
||||
event = spa_pod_builder_pop(&b, &f[0]);
|
||||
|
||||
spa_device_emit_event(&this->hooks, event);
|
||||
|
|
@ -857,8 +857,6 @@ struct acp_card_events card_events = {
|
|||
.port_available = card_port_available,
|
||||
.volume_changed = on_volume_changed,
|
||||
.mute_changed = on_mute_changed,
|
||||
.set_soft_volume = on_set_soft_volume,
|
||||
.set_soft_mute = on_set_soft_mute,
|
||||
};
|
||||
|
||||
static int impl_get_interface(struct spa_handle *handle, const char *type, void **interface)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue