pulse-server: improve sink/source state

When a sink is RUNNING but there is nothing linked to the input it must
be the monitor that is keeping it active, report IDLE for the sink in
that case.

When a source is RUNNING but there is nothing linked to the output it
must be the sink part that is keeping it active, report IDLE for the
source.

Fixes #1345
This commit is contained in:
Wim Taymans 2021-06-25 13:23:22 +02:00
parent eb262beb22
commit 0c14ec769f
3 changed files with 44 additions and 3 deletions

View file

@ -3467,11 +3467,19 @@ static int fill_sink_info(struct client *client, struct message *m,
TAG_INVALID);
}
if (client->version >= 15) {
bool is_linked = collect_is_linked(manager, o->id, SPA_DIRECTION_INPUT);
int state = node_state(info->state);
/* running with nothing linked is probably the monitor that is
* keeping this sink busy */
if (state == STATE_RUNNING && !is_linked)
state = STATE_IDLE;
message_put(m,
TAG_VOLUME, dev_info.volume_info.base, /* base volume */
TAG_U32, node_state(info->state), /* state */
TAG_U32, state, /* state */
TAG_U32, dev_info.volume_info.steps, /* n_volume_steps */
TAG_U32, card_id, /* card index */
TAG_U32, card_id, /* card index */
TAG_INVALID);
}
if (client->version >= 16) {
@ -3611,9 +3619,17 @@ static int fill_source_info(struct client *client, struct message *m,
TAG_INVALID);
}
if (client->version >= 15) {
bool is_linked = collect_is_linked(manager, o->id, SPA_DIRECTION_OUTPUT);
int state = node_state(info->state);
/* running with nothing linked is probably the sink that is
* keeping this source busy */
if (state == STATE_RUNNING && !is_linked)
state = STATE_IDLE;
message_put(m,
TAG_VOLUME, dev_info.volume_info.base, /* base volume */
TAG_U32, node_state(info->state), /* state */
TAG_U32, state, /* state */
TAG_U32, dev_info.volume_info.steps, /* n_volume_steps */
TAG_U32, card_id, /* card index */
TAG_INVALID);