bluetooth: split BT codec from A2DP SEP configuration api

Common API for all bluetooth codecs is now pa_bt_codec.
API to negotiate and configure A2DP SEP over Bluez is now pa_a2dp_endpoint_conf.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507>
This commit is contained in:
Igor V. Kovalenko 2021-03-02 21:33:24 +03:00 committed by PulseAudio Marge Bot
parent c7c9ca22ab
commit 310e2877a0
12 changed files with 322 additions and 275 deletions

View file

@ -29,67 +29,67 @@
#include "a2dp-codec-util.h"
extern const pa_a2dp_codec pa_bt_codec_msbc;
extern const pa_a2dp_codec pa_bt_codec_cvsd;
extern const pa_bt_codec pa_bt_codec_msbc;
extern const pa_bt_codec pa_bt_codec_cvsd;
/* List of HSP/HFP codecs.
*/
static const pa_a2dp_codec *pa_hf_codecs[] = {
static const pa_bt_codec *pa_hf_codecs[] = {
&pa_bt_codec_cvsd,
&pa_bt_codec_msbc,
};
extern const pa_a2dp_codec pa_a2dp_codec_sbc;
extern const pa_a2dp_codec pa_a2dp_codec_sbc_xq_453;
extern const pa_a2dp_codec pa_a2dp_codec_sbc_xq_512;
extern const pa_a2dp_codec pa_a2dp_codec_sbc_xq_552;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_453;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_512;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_sbc_xq_552;
#ifdef HAVE_GSTAPTX
extern const pa_a2dp_codec pa_a2dp_codec_aptx;
extern const pa_a2dp_codec pa_a2dp_codec_aptx_hd;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_aptx;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_aptx_hd;
#endif
#ifdef HAVE_GSTLDAC
extern const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_hq;
extern const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_sq;
extern const pa_a2dp_codec pa_a2dp_codec_ldac_eqmid_mq;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_hq;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_sq;
extern const pa_a2dp_endpoint_conf pa_a2dp_endpoint_conf_ldac_eqmid_mq;
#endif
/* This is list of supported codecs. Their order is important.
* Codec with lower index has higher priority. */
static const pa_a2dp_codec *pa_a2dp_codecs[] = {
static const pa_a2dp_endpoint_conf *pa_a2dp_endpoint_configurations[] = {
#ifdef HAVE_GSTLDAC
&pa_a2dp_codec_ldac_eqmid_hq,
&pa_a2dp_codec_ldac_eqmid_sq,
&pa_a2dp_codec_ldac_eqmid_mq,
&pa_a2dp_endpoint_conf_ldac_eqmid_hq,
&pa_a2dp_endpoint_conf_ldac_eqmid_sq,
&pa_a2dp_endpoint_conf_ldac_eqmid_mq,
#endif
#ifdef HAVE_GSTAPTX
&pa_a2dp_codec_aptx_hd,
&pa_a2dp_codec_aptx,
&pa_a2dp_endpoint_conf_aptx_hd,
&pa_a2dp_endpoint_conf_aptx,
#endif
&pa_a2dp_codec_sbc,
&pa_a2dp_codec_sbc_xq_453,
&pa_a2dp_codec_sbc_xq_512,
&pa_a2dp_codec_sbc_xq_552,
&pa_a2dp_endpoint_conf_sbc,
&pa_a2dp_endpoint_conf_sbc_xq_453,
&pa_a2dp_endpoint_conf_sbc_xq_512,
&pa_a2dp_endpoint_conf_sbc_xq_552,
};
unsigned int pa_bluetooth_a2dp_codec_count(void) {
return PA_ELEMENTSOF(pa_a2dp_codecs);
unsigned int pa_bluetooth_a2dp_endpoint_conf_count(void) {
return PA_ELEMENTSOF(pa_a2dp_endpoint_configurations);
}
const pa_a2dp_codec *pa_bluetooth_a2dp_codec_iter(unsigned int i) {
pa_assert(i < pa_bluetooth_a2dp_codec_count());
return pa_a2dp_codecs[i];
const pa_a2dp_endpoint_conf *pa_bluetooth_a2dp_endpoint_conf_iter(unsigned int i) {
pa_assert(i < pa_bluetooth_a2dp_endpoint_conf_count());
return pa_a2dp_endpoint_configurations[i];
}
unsigned int pa_bluetooth_hf_codec_count(void) {
return PA_ELEMENTSOF(pa_hf_codecs);
}
const pa_a2dp_codec *pa_bluetooth_hf_codec_iter(unsigned int i) {
const pa_bt_codec *pa_bluetooth_hf_codec_iter(unsigned int i) {
pa_assert(i < pa_bluetooth_hf_codec_count());
return pa_hf_codecs[i];
}
const pa_a2dp_codec *pa_bluetooth_get_hf_codec(const char *name) {
const pa_bt_codec *pa_bluetooth_get_hf_codec(const char *name) {
unsigned int i;
for (i = 0; i < PA_ELEMENTSOF(pa_hf_codecs); ++i) {
@ -100,13 +100,13 @@ const pa_a2dp_codec *pa_bluetooth_get_hf_codec(const char *name) {
return NULL;
}
const pa_a2dp_codec *pa_bluetooth_get_a2dp_codec(const char *name) {
const pa_a2dp_endpoint_conf *pa_bluetooth_get_a2dp_endpoint_conf(const char *name) {
unsigned int i;
unsigned int count = pa_bluetooth_a2dp_codec_count();
unsigned int count = pa_bluetooth_a2dp_endpoint_conf_count();
for (i = 0; i < count; i++) {
if (pa_streq(pa_a2dp_codecs[i]->name, name))
return pa_a2dp_codecs[i];
if (pa_streq(pa_a2dp_endpoint_configurations[i]->bt_codec.name, name))
return pa_a2dp_endpoint_configurations[i];
}
return NULL;
@ -127,13 +127,13 @@ void pa_bluetooth_a2dp_codec_gst_init(void) {
bool pa_bluetooth_a2dp_codec_is_available(const pa_a2dp_codec_id *id, bool is_a2dp_sink) {
unsigned int i;
unsigned int count = pa_bluetooth_a2dp_codec_count();
const pa_a2dp_codec *a2dp_codec;
unsigned int count = pa_bluetooth_a2dp_endpoint_conf_count();
const pa_a2dp_endpoint_conf *conf;
for (i = 0; i < count; i++) {
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
if (memcmp(id, &a2dp_codec->id, sizeof(pa_a2dp_codec_id)) == 0
&& a2dp_codec->can_be_supported(is_a2dp_sink))
conf = pa_bluetooth_a2dp_endpoint_conf_iter(i);
if (memcmp(id, &conf->id, sizeof(pa_a2dp_codec_id)) == 0
&& conf->can_be_supported(is_a2dp_sink))
return true;
}