bluetooth: Add currently active codec name to card/sink/source proplist

This exposes the currently active codec on the source or sink via the
proplist and can be seen in output of pacmd list-sinks/list-sources.
Also set it on the card. In case of a bi-directional codec, the codec
for the sink and source could be different. For example, for aptX-LL,
the codec name on card, sink and source would be aptx-ll, aptx and sbc
respectively.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
This commit is contained in:
Sanchayan Maity 2020-12-31 13:59:40 +05:30
parent 2fea838e50
commit 4ce996b74a
2 changed files with 14 additions and 0 deletions

View file

@ -1000,6 +1000,8 @@ static int add_source(struct userdata *u) {
data.name = pa_sprintf_malloc("bluez_source.%s.%s", u->device->address, pa_bluetooth_profile_to_string(u->profile));
data.namereg_fail = false;
pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bluetooth_profile_to_string(u->profile));
if (u->a2dp_codec)
pa_proplist_sets(data.proplist, PA_PROP_BLUETOOTH_CODEC, u->a2dp_codec->name);
pa_source_new_data_set_sample_spec(&data, &u->decoder_sample_spec);
if (u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT)
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
@ -1184,6 +1186,8 @@ static int add_sink(struct userdata *u) {
data.name = pa_sprintf_malloc("bluez_sink.%s.%s", u->device->address, pa_bluetooth_profile_to_string(u->profile));
data.namereg_fail = false;
pa_proplist_sets(data.proplist, "bluetooth.protocol", pa_bluetooth_profile_to_string(u->profile));
if (u->a2dp_codec)
pa_proplist_sets(data.proplist, PA_PROP_BLUETOOTH_CODEC, u->a2dp_codec->name);
pa_sink_new_data_set_sample_spec(&data, &u->encoder_sample_spec);
if (u->profile == PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT)
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
@ -1643,6 +1647,10 @@ static int start_thread(struct userdata *u) {
u->source->set_volume(u->source);
}
if (u->sink || u->source)
if (u->a2dp_codec)
pa_proplist_sets(u->card->proplist, PA_PROP_BLUETOOTH_CODEC, u->a2dp_codec->name);
return 0;
}
@ -1650,6 +1658,9 @@ static int start_thread(struct userdata *u) {
static void stop_thread(struct userdata *u) {
pa_assert(u);
if (u->sink || u->source)
pa_proplist_unset(u->card->proplist, PA_PROP_BLUETOOTH_CODEC);
if (u->sink)
pa_sink_unlink(u->sink);

View file

@ -270,6 +270,9 @@ PA_C_DECL_BEGIN
/** For context: whether to forcefully disable data transfer via POSIX or memfd shared memory. This property overrides any other client configuration which would otherwise enable SHM communication channels. \since 15.0 */
#define PA_PROP_CONTEXT_FORCE_DISABLE_SHM "context.force.disable.shm"
/** For a bluez device: the currently selected codec name. \since 15.0 */
#define PA_PROP_BLUETOOTH_CODEC "bluetooth.codec"
/** A property list object. Basically a dictionary with ASCII strings
* as keys and arbitrary data as values. \since 0.9.11 */
typedef struct pa_proplist pa_proplist;