device-port: queue CARD CHANGE event before update default sink
authorLibin Yang <libin.yang@intel.com>
Sat, 13 Jun 2020 10:27:08 +0000 (06:27 -0400)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 22 Jun 2020 14:53:42 +0000 (14:53 +0000)
commit2ae94c141ff4d76d60a66a71d80acefbba3966d1
treeec39a006bba1f3583ae1e6e50fff091e1e37d344
parent04c554b7d5ece918e4c5456bec491380b8d24791
device-port: queue CARD CHANGE event before update default sink

In single profile mode (headphone and speaker use different PCMs),
when headphone is plugged in, pa_device_port_set_available() will call
pa_core_update_default_sink/source() before posting
PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE to the gnome.
And pa_core_update_default_sink/source() will post
PA_SUBSCRIPTION_EVENT_SERVER | PA_SUBSCRIPTION_EVENT_CHANGE to the gnome.
So the original event sequence is:
1. PA_SUBSCRIPTION_EVENT_SERVER | PA_SUBSCRIPTION_EVENT_CHANGE
2. PA_SUBSCRIPTION_EVENT_CARD | PA_SUBSCRIPTION_EVENT_CHANGE

In gnome-control-center:
When it receives PA_SUBSCRIPTION_EVENT_SERVER, it will call
req_update_server_info () to update the panel;
When it receives PA_SUBSCRIPTION_EVENT_CARD, it will update
the card information, for example, when the headphone is connected,
it will call gtk_list_store_append() to append the headphone.

Let's use an example to clarify the correct sequence.
Assume we plug in headphone. PA will set the default sink to headphone
from speaker, and hope gnome sound setting "Output Deivce" to highlight to
"headphone". PA should send PA_SUBSCRIPTION_EVENT_CARD firstly to notify
gnome-control-center "headphone" is plugged in. And then it sends
PA_SUBSCRIPTION_EVENT_SERVER to trigger sound setting to highlight
to "headphone".

Signed-off-by: Libin Yang <libin.yang@intel.com>
src/pulsecore/device-port.c